This is a very basic tutorial on setting up samba in linux.Samba as you know is used to share files over the network with windows machines.Setting samba up is not that difficult , it involves following a few steps and some editing as well in between.So here it is

Step 1: Firstly, Samba needs to be installed.Go to the terminal(Applications->Accessories->Terminal) and type
sudo apt-get install samba smbfs
Enter your sudo password and the installation should now begin.Hit Y if asked to confirm the installation
Step 2: Once you have samba installed, You need to add samba users .
NOTE: Only system users can be allowed to create samba users.So you can either use your current username which you use to login to ubuntu or you can create a new System user by going to System->Administration->Users and Groups and clicking on "Add User",then fill in the details like username(this will be the samba username as well) , also enter a password and then click on OK


Step 3: To add samba users , in the terminal type
sudo smbpasswd -a sysusername
where sysusername is the system username which can either be the one you use to login to ubuntu or the one you created in step 2
Step 4: Incase you want to add more than one user follow steps 2 and 3 again.
Step 5: Now you need to add these users to the smbusers file.In the terminal type
gksudo gedit /etc/samba/smbusers
TextEditor should now open with the smbusers file.Now add the following line to the file
sysusername = "network username"
Again replace sysusername with the username you already created in step 3 .. If you have created many users then copy paste these lines again replacing sysusername with the username you created in step 3.After you are done with it, save the file and close it
Step 6: Now you need to enable the network username you created.In the terminal type
sudo smbpasswd -e sysusername
Again replace sysusername with the username you created in step 3.For multiple users type the same command again and replace sysusername with the network username you created in step 3
Step 7: Now in the terminal type
gksudo gedit /etc/samba/smb.conf
Find the following line
; security = user
and replace it with
security = user username map = /etc/samba/smbusers

Save and close the file.This is basically telling samba to look at the smbusers file for username information for authentication
Step 8: Now type sudo /etc/init.d/samba restart to restart samba
Step 9: The basic setup is done.Now its time to share files, You can do this in two ways- the graphical way or the command line way.I'll show you both ways

THE COMMAND LINE WAY
In the terminal type gksudo gedit /etc/samba/smb.conf and add the following lines to the end of the file

[sharename] comment = Any comment you like
path = /media/drive

public = yes

writable = yes

create mask = 0777

directory mask = 0777

force user = nobody

force group = nogroup


Here replace /media/drive with the path to the folder you want to share.If you want that folder to be read-only then change writable = yes to writable = no .If you want to allow users to write then leave writable = yes as it is.Also replace sharename with any name you want

THE GRAPHICAL WAY
This is pretty straight forward.Right click on the folder you want to share and click on "share folder" and type the sudo password.Then replace DO NOT SHARE with WINDOWS NETWORKS(SMB).Enter the name of the share as you like.Incase you want it to be read-only then check Read-only else uncheck it.And then click on OK.



Step 10: After all this is done.Restart samba by typing sudo /etc/init.d/samba restart and you are good to go

NOTE: To access the samba shares from this computer from a windows machine type \\(pc name or pc ip) .from a ubuntu machine type smb://(pc name or pc ip)

13 comments

Anonymous said... @ August 1, 2008 at 1:04 AM

Thanks for your post. Question - does this work for a partition (ie my shared workarea is an NTFS partition, not just a folder). Thanks

Anonymous said... @ August 1, 2008 at 2:42 AM

yes it could.. typically each partition is under /media .. so say the partition has a name part .. so you could create s share for /media/part

Anonymous said... @ September 30, 2008 at 2:44 AM

Hi there,

I am sorry to say, but this does not work for me. I have no "Share Folder" option on right click, only "Sharing options" and this gives me a totally different dialog.

I also cannot access any Windows shares on the LAN.

What am I doing wrong?

Anonymous said... @ September 30, 2008 at 3:41 AM

which distro are you running??You could do it the command line way as shown in the article.. by adding lines to the smb.conf file

Anonymous said... @ September 30, 2008 at 9:40 AM

Ubuntu 8.04.

Been told that there is a bug and that it won't work properly until they fix it.

SydOracle said... @ October 18, 2008 at 2:41 AM

Ubuntu 8.04 - The GUI Shared folder bit didn't work, but the command line version did. Much appreciated.

michaelso@gmail.com said... @ April 22, 2009 at 11:00 AM

gksudo gedit/etc/samba/smbusers

This command did not open up the text editor. I tried to find the file in the \etc\samba folder. It's not there.

Prash Babu said... @ April 22, 2009 at 10:47 PM

its sudo gedit /etc/samba/smbusers
If the file doesnt exist.. create one..

oes tsetnoc said... @ September 27, 2009 at 7:11 PM

The FILES section of the manpage for `smbd' may give some hints. I don't have any Solaris box handy, so cannot unfortunately confirm. You can do also the test parameter commands like this # /etc/samba/smb.conf

Unknown said... @ June 20, 2010 at 7:56 PM

thank you for giving this information

Anonymous said... @ April 9, 2011 at 11:06 AM

I have ubuntu 9. I tried to run the command /etc/init.d/samba ie step 8, it gives me some errors. I checked the file init.d if I could find samba but saw nothing. Pls what can I do in step 8.

Anonymous said... @ November 10, 2011 at 8:59 AM

In Ubuntu 11.10, you restart Samba like this:

sudo service smbd restart
sudo service nmbd restart

You can always replace "restart" with "start" or "stop" if needed (without quotes of course).

Anonymous said... @ July 11, 2013 at 9:37 PM

Hello

I tried to get Samba and got the same "Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/c/cifs-utils/cifs-utils_4.5-2ubuntu0.11.04.1_i386.deb 404 Not Found" error.

What can you do if it cannot find the package?

Regards


Anthony

Post a Comment