There is a new revision of this tutorial available for Ubuntu 16.04 (Xenial Xerus).

Samba Server Configuration in Ubuntu 14.04 LTS

This guide explains how to configure samba server in Ubuntu 14.04 with anonymous & secured samba servers. Samba is an Open Source/Free Software suite that provides seamless file and print services to SMB/CIFS clients. Samba is freely available, unlike other SMB/CIFS implementations, and allows for interoperability between Linux/Unix servers and Windows-based clients.

I do not issue any guarantee that this will work for you!

1 Preliminary Note

I have fresh installed ubuntu14.04 server, on which I am going to install the samba server. Off-course you need to have one windows machine to check the  samba server that must be reachable with the ubuntu server. My ubuntu server have hostname & IP as

You can have your ubuntu server installed from the starting eleven chapters of this tutorial.


  • The Windows machine must be on same workgroup. To check the value in windows machine run the command at cmd prompt

net config workstation

It will be like this

Your windows machine must be at same Workstation domain as in ubuntu server, i.e. WORKGROUP in my case.
  • To make the windows machine reachable in windows proceed like this. In the run terminal & add  the entry of your server IP address

notepad C:\Windows\System32\drivers\etc\hosts

In my case it was like this, just save the values.

[...] ubuntu

2 Anonymous samba sharing

First I will explain the methodology to install the samba with the anonymous sharing. To install samba run,

apt-get install samba samba-common python-glade2 system-config-samba

It will install samba with version 4.1.6-Ubuntu.

Now to configure samba edit the file /etc/samba/smb.cnf before making changes I will make the backup of original file as  /etc/samba/smb.cnf.bak

mv /etc/samba/smb.cnf /etc/samba/smb.cnf.bak

Further give the entries like this

vi /etc/samba/smb.cnf

workgroup = WORKGROUP
server string = Samba Server %v
netbios name = ubuntu
security = user
map to guest = bad user
dns proxy = no
#============================ Share Definitions ============================== 
path = /samba/anonymous
browsable =yes
writable = yes
guest ok = yes
read only = no

mkdir -p /samba/anonymous

service smbd restart

Now you can access the ubuntu sharing in windows as follows:

From windows machine just browse the folder& try to create a text file, but you will get an error of permission denied.

Check the permission for the shared folder.

[email protected]:~# ls -l /samba/
total 4
drwxr-xr-x 2 root root 4096 May 27 18:17 anonymous
[email protected]:~#

To allow anonymous user give the permissions as follows;

[email protected]:~# cd /samba
[email protected]:/samba# chmod -R 0755 anonymous/
[email protected]:# chown -R nobody:nogroup anonymous/
[email protected]:/samba# ls -l
total 4
drwx-xr-x 2 nobody nogroup root 4096 May 27 18:17 anonymous
[email protected]:/samba#

Now anonymous user can browse & create the folder contents.

You can cross check the content at server also.

[email protected]:/samba# ls -l anonymous/
total 0
-rwxr--r-- 1 nobody nogroup 0 May 27 18:30 test_samba.txt
[email protected]:/samba#

3. Secured samba server

For this I will create a group smbgrp & user srijan to access the samba server with proper authentication

addgroup smbgrp

adduser srijan -G smbgrp

smbpasswd -a srijan

[email protected]:~# smbpasswd -a srijan
New SMB password:
Retype new SMB password:
Added user srijan.
[email protected]:~#

Now create the folder viz secured in the /samba folder & give permissions like this

mkdir -p /samba/secured
cd /samba
chmod -R 0770 secured/

Again edit the configuration file as :

vi /etc/samba/smb.conf

 path = /samba/secured
 valid users = @smbgrp
 guest ok = no
 writable = yes
 browsable = yes

service smbd restart 

Further to cross-check the settings check as follows:

[email protected]:~# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[Anonymous]"
Processing section "[secured]"
Loaded services file OK.
Press enter to see a dump of your service definitions

Now at windows machine check the folder now with the proper credentials

You will again face the issue of permissions to give write permission to the user srijan do:

cd /samba
chown -R srijan:smbgrp secured/

Now samba user srijan  have permissions to write in the folder. Cheers you have done with samba server in Ubuntu14.04.

Share this page:

25 Comment(s)

Add comment


From: Sankari Prosad

why are you giving 777 permission to anonymous folder.As far as I know giving execute permission(where you don't need) on a folder is not a good security practice.

 Apart from that..nice tutorial.thanks.

From: Steve

Terrific tutorial. Worked perfect the first time. Thanks!


Hi Srijan,

 As always beautiful work! But I think there is a letter missing. Not sure, as you know I'm not that great at Linux. I think the config file is called smb.conf !? Just helping in case a newbie like myself comes across this problem.

Thanks for the great tutorial!!!

 Kind Regards



Hello again,

Forgot this. Regarding the "mv" command. Isn't this removing the conf file. Making a backup file, yes, but we do need the original smb.conf to modify do we not?

Well, I'm probably wrong. Just didn't get it...

From: Keith

You have succeded wher others have failed. I couldnt get Samba working at all but this tut got it working first time. I nearly fell off the chair.

 well done, and thanks


From: Muhammad Bashir Al-Noimi

Thanks for greate post but my PC unseen by Windows PCs althouth they are on same workgroup!

How can I fix this issue?

From: Muhammad Bashir Al-Noimi

I forgot to mention that Windows PCs has Windows 8.1 Pro x64

From: Dennis

Thanks, very nice how-to!

From: Baltazar Pupkin

Do you know difference between /etc/samba/smb.conf and /etc/samba/smb.cnf ?


From: Gary

typo, bro! 

From: Gary

Great stuff!!! Follow on question:

1) if instead of the smbgrp, I wanted to giver permission to user 'xyz', could I just put 'xyz' as valid users in smb.conf?

2) If I wanted to allow 2 or 3 users access to a Share, but not have them in a  group, could I just put 'xyz, abc, def' as valid users in smb.conf?  In other words, can I put a list of users separated by commas?

From: dinesh reddy

see guyss please tell how to see windows xp share floder from ubuntu system 

From: pascal62fr

Bonjour, j'ai apprécié que vous ayez commencé par un exemple de smb.conf simple a comprendre et a mettre en oeuvre. TY

From: Caio

In case you're getting the error "Access Denied" after trying to write anything in Anonymous public share, try to change "smb.conf" the following way: 


#============================ Share Definitions ============================== [Anonymous] path = /samba/anonymous browsable = yes writable = yes guest ok = yes read only = noforce user = nobody

That's it! Good luck!

From: Abhishek Kumar

How to add multiple directory in secured section smb.conf file?

From: Furqon Mauladani

Splendid, this tutorial is very complete. Thx

From: mansoor

nice tutor

keep it up guy.

From: Mark

Well done. This was the first tutorial I came across that actually helped! Thank you.

From: thomas

do you have a config für a group of users, that use files and directories as they want?

I tried a lot, but always find some greyed "special rights" on the windows clients instead of clear rights given in solid black.

I would like:

file of the group: group can do anything incl. modify, delete and change rights

folder of the group: group can do anything incl. making subdirs and delete

instead I get folders that can only be altered in their rights by the owner

From: lars

After: "chmod -R 0770 secured/"I would add : "sudo chown -R root:smbgrp samba/secured/"I.e. add group "smbgrp" to samba/secured. Not sure.

From: ihtiar

thanks for articles i have vinis settiing the samba....

From: Surja

Thank you for this perfect tutorial. This is the only tutorial that I have found till now which works.

From: Ralosoft

Excellent, my smb.conf was longer and it did not work, with this tutorial now its working samba.

Only a question, i tried to share a folder of another disk, it didnt work. any idea what i couldnt share my folder.

From: Frank Kuijpers

I want to install this on a Virtual Server in the cloud. How do I connect to the server then? With something like  smb://192.168.x.x ??

From: Vic Silvano


I think there something wrong about adding group. I follow the steps below but the server says "Option g is ambigous (gecos, gid group). I think there something wrong that code below. Anyone who has a bright idea?..""

adduser srijan -G smbgrp 

thanks a lot. . .