Samba File sharing

Samba, a free, open source implementation of windows file sharing. It allows you to store your files on a unix OS and sharing it across the network and platforms. (This tutorial is for setting up samba on Ubuntu 9.04 Jaunty)

Install Samba

First of all you will need to install the samba server if it is not installed already

sudo apt-get install samba

Follow the installation process until you get back to the terminal window

Theoretically every thing should be setup correctly now. But unfortunately it is seldom the case. We will have to manualy configure the config file.

Creating the config file

The config file path is by default

/etc/samba/smb.config

Some times it is just easier to create a new config file so first we will have to backup the default config file. Here is how to back it up

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

Now we can create a blank config file, but we will first have to remove what is still there

sudo rm /etc/samba/smb.conf

Create the blank config file

sudo touch /etc/samba/smb.conf

Configuring the Config file

Open the file in a text editor (I'll be using the vi editor)

cd /etc/samba/
sudo vi smb.conf

Insert the following into the config file. You will have to change some of the value to suite your requirements

[global]
workgroup = YourWorkgroupName
security = share
#Example Shared Folder
[SharedFolderName]
comment = A Comment
path = /path/to/the/folder/
public = yes
writeable = yes
create mask = 0777

Above code explained

Replace “YourWorkgroupName” with the workgroup your system is setup with. It is normally HOME, MSHOME or WORKGROUP

    workgroup = YourWorkgroupName

The Security is set to allow access for any one on the network to view/create/edit files on your shared folder

    security = share 

SharedFolderName is the name you would like the shared folder to display as. It don't have to be the same as the real folder name, but it will be the name you see when you browse the network. (It must be in square brackets)

    [SharedFolderName] 

The comment is just what it says, it is a comment about the shared folder

    comment = A Comment

The path is the true path to the folder that you would like to share

    path = /path/to/the/folder/ 

The “public” command allows everyone on the network access to the folder

    public = yes

The “writeable” command allows for the creation of files or for the editing of current files

    writeable = yes

The “create mask” command sets the permissions for all newly created files.

    create mask = 0777

Add additional shared folders

To add additional shared folders to the config file you can add more folders with their specific commands

[global]
  workgroup = YourWorkgroupName
  security = share

  #Example Shared Folder
  [SharedFolderName]
  comment = A Comment
  path = /path/to/the/folder/
  public = yes
  writeable = yes
  create mask = 0777

  [SharedFolder2Name]
  comment = A Comment
  path = /path/to/the/folder2/
  public = yes
  writeable = yes
  create mask = 0777

  [SharedFolder3Name]
  comment = A Comment
  path = /path/to/the/folder3/
  public = yes
  writeable = yes
  create mask = 0777

After configuring the file save it.

Restart the Samba server

After you have modified your config file you need to restart samba so that it can reload the modified config file

sudo /etc/init.d/samba force-reload

Samba should restart normally. If you encounter problems check your config file

File permissions

You will still have to give file permissions to everyone before they can access any of the files. Use the -R command to give recursive permissions to all files in the folder.

sudo chmod 777 /path/you/have/shared/ -R
 
/home/dodgydevil/wiki.zendfusion.com/data/pages/other/linux/samba.txt · Last modified: 2009/10/27 01:39 by bosbaba
[unknown button type]
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Zend Fusion