Today I will show you how to configure file sharing on Ubuntu 12.04 LTS. This tutorial works for both the desktop and server variations.
First thing is to install the packages we need – Samba and smbfs. So open up a terminal and type:
sudo apt-get install samba
Type your root password when prompted. Then install smbfs by typing:
sudo apt-get install smbfs
and then type your root password again.
We now have to configure the smb.conf file which contains all the samba settings. In a terminal type:
gksu nano /etc/samba/smb.conf
Locate the line WORKROUP = WORKGROUP and change it to the name of your network. So for instance mine would be changed to WORKGROUP = Ubuntu_home.
Now at the end of the file add the following text:
[sdc] (This is the name of your share – change as appropriate)
path = /media/dev/sdc (This is the network path to your share – change as appropriate)
available = yes
browsable = yes
public = yes
writable = yes
comment = shared files
Save the file and exit.
If you prefer GUI’s (Desktop Ubuntu only) then you can install the Samba gui instead and share your folders that way.
Now we have to add users to the smbpasswd file which is located at /etc/samba/smbpasswd. Only users specified in the smbpasswd file will be able to access your samba shares. Open a terminal and type:
sudo smbpasswd -a user (where user is the name of the person allowed to access the shares)
When prompted enter their new password twice.
We now need to restart the samba service so in a terminal type:
sudo service smbd restart
Now we have to check the configuration so far. In a terminal type:
Testparm will tell you if there are any errors in your configuration. If everything is Ok then type:
smbclient -L 192.168.1.10 (where 192.168.1.10 is the ip address of your samba server).
This will show you the list of all your available samba shares. At this point if you have no errors your server is configured correctly.
Install samba and smbfs either using the package manager or the terminal. We need to edit the Workgroup field in smb.conf to the name of your network (e.g Ubuntu_home).
Then we have to mount the available shares. First decide where you are going to mount them. I will mount them in /media/dev/share but first I will have to make the directory dev so:
sudo mkdir dev
and then ls which should show us the new dev directory in media. Now time to mount the shares.
sudo mount -t smbfs //192.168.1.10/(share name) /media/dev/share where 192.168.1.10 is the ip address of your samba server. This will mount the share but only as long as you are logged in. To make the link persistent you need to enter the following line into /etc/fstab.
//192.168.1.10/(share) /media/dev/share cifs username=user,password=pass,user,rw,noatime 0 0
We have to change the workgroup to Ubuntu_home and then add the ip address of the samba server to the hosts file (must open as administrator).
Once this is complete map the shares to your computer.
Word of warning here about firewalls. Either turn them off or add exception rules for traffic on ports 137-139 and 445.
About the Author
Hi I am Chris Wakefield the owner of ComTech IT Support. I provide Windows and Linux based IT Support, laptop repairs and computer repairs to both business and personal clients in and around Stirling.
For a list of what I can offer you why not visit my website www.comtech247.net where you will find a list of my services, testimonials, blog and much more.