SAMBA is very well known Opensource applications for file and printer sharing server in Unix and Linux. It supports the Server Message Block (SMB) and Common Internet File System (CIFS) protocols used by Microsoft operating systems. So, it is an effective application for sharing files between Linux and Windows computers in a Network. It can also be configured as many different deployment options such as Lightweight Directory Access Protocol (LDAP) server, Kerberos authentication server and Active Directory Servers (Windows Domain Controller). Now, I will guide you to install and configure it in very easy way.
First, install SAMBA serve in your PC. Open terminal and type following command
sudo apt-get install samba smbfs
Now, you will have to configure it for file sharing and user access.
sudo gedit /etc/samba/smb.conf
here, you will have to edit several sections in this configuration file. Let start the first one. Find the following section
<blockquote>####### Authentication ####### # “security = user” is always a good idea. This will require a Unix account # in this server for every user accessing the server. See # /usr/share/doc/samba-doc/htmldocs/Samba-HOWTO-Collection/ServerType.html # in the samba-doc package for details. ; security = user
Then uncomment the security line, and add another line under that. Finally it will be like this:
security = user username map = /etc/samba/smbusers
Now, you will have to create SAMBA user. Let, your username is testuser. So type this
sudo smbpasswd -a testuse
The smbpasswd application will then prompt you to enter a password for this user. if you get any failure message, then add user in following way.
useradd -s /bin/true testuse
Next, add this username to the smbusers file. Open the smbusers file
sudo gedit /etc/samba/smbusers
add follwoing line
username = "testuse"
Save and close it. User is created. Now you will have to configuring it for file sharing. Again edit the conf file.
sudo gedit /etc/samba/smb.conf
Find the Share Definition section, make that like following
<blockquote>#======================= Share Definitions ======================= # Un-comment the following (and tweak the other settings below to suit) # to enable the default home directory shares. This will share each # user’s home directory as \\server\username [share] comment = Ubuntu File Server Share path = /srv/samba/share browsable = yes guest ok = no read only = no writable = yes create mask = 0755
Let me explain each values
- comment: a short description of the share
- path: the path to the directory to share.You can set your own path of directory, which one your want to share in network
- browsable: enables Windows clients to browse the shared directory using Windows Explorer.
- guest ok: allows clients to connect without supplying a password. Make it no for prompting password
- read only: determines if the share is read only or if write privileges are granted.
- writable: allows clients to write privileges
- create mask: determines the permissions new files will have when created.
Now the SAMBA server is configured. Change the directory’s permissions.
[cc lang=”lang”]sudo mkdir -p /srv/samba/share
sudo chown nobody.nogroup /srv/samba/share/[/cc]
Finally, restart the samba services . .
sudo restart smbd sudo restart nmbd
Done. Go to any windows PC, then start->run a and following line.
\\SAMBA server ip address\share
It will prompt for username and password. Enter the username: testuser and the password that your entered before. In Linux click on network. It will also prompt username and password. Now, whatever you will keep in /srv/samba/share directories, all Linux and windows computer will get access to those files.