Thursday, December 20, 2012

Sharing a Folder in Linux Ubuntu 12.04

One of the most common ways to share a folder on Ubuntu system is to configure Samba File Server. These Steps will help to configure Samba server to share files and folders in network.

1. First install the samba package from terminal by typing the following command
sudo apt-get install samba

after completion of successful installation we can share a folder directly by right click on a folder and select share folder option.

If you want to provide a secure access to that folder then we need to change the Samba server configuration file.
The Samba configuration file is located in /etc/samba/smb.conf.
Edit the pairs in the [global] section of /etc/samba/smb.conf file:
  workgroup = EXAMPLE
  security = user
Uncomment the security parameter which is commented by default and also change EXAMPLE to match your environment.

Create a new section at the bottom of the file like this:

   comment = Ubuntu File Server Share
   path = /svr/samba/share
   browsable = yes
   guest ok = yes
   read only = no
   create mask = 0755

comment: a short description of the shared file.

path: path to the directory to share.

In this example i use /svr/samba/sharefoldername because, /svr is where site-specific data should be served. Samba shares can be placed anywhere on the filesystem as long as the permissions are correct, but adhering to standards is recommended.

browsable: enables Windows users to browse the shared directory and files using Windows Explorer.

guest ok: allow clients to connect to the shared folder without entering a password.

read only: determines if the share folder is read only or if write privileges are granted. if the value is no then write privileges are allowed, if the value is yes then the privileges are set to read only.

create mask: determines the permissions to new files  will have when created.

Now the Samba Server is configured, then we need to create the directory and change the permissions.
Open Terminal and type the following commands:
sudo mkdir -p /srv/samba/share
sudo chown nobody.nogroup /srv/samba/share/

The -p switch tells mkdir to create the entire directory tree if it doesn't exist.

Finally restart the samba services to enable the new configuration:

sudo restart smbd
sudo restart nmbd

No comments:

Post a Comment