Samba Server installation on Ubuntu 16.04 LTS

This guide explains the installation and configuration of a Samba server on Ubuntu 16.04 (Xenial Xerus) with anonymous and secured Samba shares. 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.

1 Preliminary Note

I have a freshly installed Ubuntu 16.04 LTS server, on which I am going to install the samba server. As Samba client system, I will use a Windows Desktop to connect to the samba server and check the setup. The Windows Desktop should be on the same network so that it is able to reach the Ubuntu server. The hostname of my Ubuntu server is and the IP is

If you don't have an Ubuntu server already, follow this tutorial to get a minimal server setup as the basis for this tutorial.

Note: The Windows machine must be in the same workgroup. To check the value on the Windows machine run the following command at cmd prompt:

net config workstation

The output will be like this:

Get the Windows Workgroup name.

Your Windows machine must be in the same Workstation domain as the Ubuntu server, i.e. WORKGROUP in my case.

To make the windows machine reachable in Windows by its hostname, proceed like this. Open a Windows terminal in administrator mode (you can reach the administrator mode by doing a right-click on the Terminal icon in the program menu) and run the following command to open the Windows hosts file:

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

There you add the following red line and save the file:

[...] server1

The following steps have to be run as root user. Run:

sudo -s

on the shell of your Linux server to become the root user.

2 Anonymous Samba sharing

Samba is available in the Ubuntu repositories. The first step is to install the Samba Server and its dependencies with apt.

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

It will install the Samba version 4.3.9-Ubuntu.

To configure samba, edit the file /etc/samba/smb.conf. I will use nano as editor and make a backup of the original file before I start to change it. The backup file is named /etc/samba/smb.conf.bak

cp -pf /etc/samba/smb.conf /etc/samba/smb.conf.bak
cat /dev/null  > /etc/samba/smb.conf

Open the Samba configuration file with nano:

nano /etc/samba/smb.conf

And add the following lines.

workgroup = WORKGROUP
server string = Samba Server %v
netbios name = ubuntu
security = user
map to guest = bad user
dns proxy = no

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

Then I'll create a directory for the anonymous share.

mkdir -p /samba/anonymous

Set the correct permissions.

chmod -R 0775 /samba/anonymous
chown -R nobody:nogroup /samba/anonymous

And restart Samba to apply the new configuration.

service smbd restart

Now you can access the Ubuntu sharing in Windows by entering "\\server1" in the windows search field of the menu or use the network browser of the Windows file explorer to connect to the share.

The Samba anonymous share shows up in Windows.

Try to upload a file by Drag&Drop to the share to see if it is working correctly.

The Upload to the anonymous Samba share was successful.

You can cross check the content at server also.

ls -la /samba/anonymous/
[email protected]:/samba/anonymous# ls -la /samba/anonymous/
total 16
drwxrwxr-x 2 nobody nogroup 4096 Jun 1 18:46 .
drwxr-xr-x 3 root root 4096 Jun 1 18:39 ..
-rwxr--r-- 1 nobody nogroup 7405 Jun 1 18:42 test.odt
[email protected]:/samba/anonymous#

3 Secured Samba server

For the password-protected share, I will create a group smbgrp and user till to access the Samba server. I'll use "howtoforge" as password in this example, please choose a custom and secure password on your server.

addgroup smbgrp
useradd till -G smbgrp
smbpasswd -a till
[email protected]:~# smbpasswd -a till
New SMB password:<--howtoforge
Retype new SMB password:<--howtoforge
Added user till.
[email protected]:~#

Now create the folder with the name "secured" in the /samba folder and give permissions like this

mkdir -p /samba/secured
cd /samba
chmod -R 0770 secured
chown root:smbgrp secured

Edit the Samba configuration file and add the following (red) lines at the end of the file:

nano /etc/samba/smb.conf

[secured] path = /samba/secured valid users = @smbgrp guest ok = no writable = yes browsable = yes
service smbd restart 

To cross-check the settings, run this command:

[email protected]:/samba# 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 <-- Press Enter
# Global parameters
netbios name = UBUNTU
server string = Samba Server %v
security = USER
map to guest = Bad User
dns proxy = No
idmap config * : backend = tdb

path = /samba/anonymous
force user = nobody
read only = No
guest ok = Yes

path = /samba/secured
valid users = @smbgrp
read only = No

At the Windows machine, open the "\\server1" network device again, it will request a username and password now. Enter the user details that you created above. In my case, the values were user=till and password=howtoforge.

Login to the Samba share.

Both Samba shares show in Windows Explorer.

The test-upload worked.

We can check the file on the Ubuntu server like this:

ls -la /samba/secured/
[email protected]:/samba# ls -la /samba/secured/
total 16
drwxrwx--- 2 root smbgrp 4096 Jun 1 19:25 .
drwxr-xr-x 4 root root 4096 Jun 1 18:49 ..
-rwxr--r-- 1 till till 7405 Jun 1 18:42 test.odt
[email protected]:/samba#

Now we have a successfully configured Samba server with an anonymous and a secured share on Ubuntu 16.04 :)

4 Virtual machine image download of this tutorial

This tutorial is available as ready to use virtual machine image in ovf/ova format that is compatible with VMWare and Virtualbox. The virtual machine image uses the following login details:

SSH / Shell Login

Username: administrator
Password: howtoforge

This user has sudo rights.

The IP of the VM is, it can be changed in the file /etc/network/interfaces. Please change all the above passwords to secure the virtual machine.

Share this page:

35 Comment(s)

Add comment

Please register in our forum first to comment.


By: Marcelo

How I upgrade Samba after Instalation?

By: till

Just update your system regularly with:


apt-get update

apt-get upgrade


this will install Samba updates as well as all other system updates.

By: Zoltan

How to create a common share?

By: John

i noticed you installed the system-config-samba which i believe it is the gui utility for samba. i did the same but gui keep crashng. any idea?

By: kashminder

after deploying the setup i can share the directory but the folder is not accessible in windows(shows folder). It says "you might not have permissions to use this network"

By: rumples

 Awesome writeup, pitty you are a rare bread amongst linux users, meaning this is the best guide to SAMBA by a long way!!!

By: Darryl

What is the purpose of creating "smbgrp" if the samba installation already creates the group "sambashare"?  Why not just use that existing group? 

By: easyrider6721

This command did not work at all,  (notepad C:\\Windows\System32\drivers\etc\hosts)

These commands did nothing .... (cp -pf /etc/samba/smb.conf /etc/samba/smb.conf.bakcat /dev/null  > /etc/samba/smb.conf)

I copied and pasted this in the window......

[global] workgroup = WORKGROUP server string = Samba Server %v netbios name = ubuntu security = user map to guest = bad user dns proxy = no #============================ Share Definitions ============================== [Anonymous] path = /samba/anonymous browsable =yes writable = yes guest ok = yes read only = noforce user = nobodyafter Opening the Samba configuration file with nano had no instructions what to do after that. couldnt save it couldnt add it to file.....I am no closer to having my server set up than i was before i read all this.... obviously i am a newbee and i am frustrated with all the how to stuff on the web with missing steps......


By: till

Thanky ou for your report. I just installed the tutorial again to verify it and there are no issues in the tutorial, all commands are working and it results in a fully working samba server. If a command does not return anything on Linux then it means that it worked, if it would not have worked then you would have gotten an error message, so the commands you posted are working file and they did exactly what they should (make a copy of the configuration file and create a new empty file.

By: ChrisG

"This command did not work at all,  (notepad C:\\Windows\System32\drivers\etc\hosts)"

File editors in windows need to be run as Administrator to access/edit the hosts file.

Rightclick on the notepad icon, then click on "Run as Administrator". 

Then click on file/open and enter "C:\\Windows\System32\drivers\etc\hosts" should now work.


By: Saku

Correct command is: notepad C:\Windows\System32\drivers\etc\hosts 

On Windows 10 you can even press right mousebutton over the startmenu and choose Windows Powershell (Admin) and write the command to there.

By: Jorge Vilela

First, thank you for the guide. It is very usefull.

But I have a problem, I created the secure samba server. But in windows when I try to use it, windows gives me an error.

"Multiple connections to a server or shared resource by the same user, using more than one user name are not allowed. Disconnect all previous connections to the server or shared resource and try again."

How can I solve this?

Thank you.

By: Aure

Hola a [email protected]!!!

Yo tenía Ubuntu 14.04 como servidor y a él se conectan equipos linux con Samba, desde que actualicé a 16.04 estuve viernes 29 Jul, sábado 30 Jul y Lunes 01 Ago. No sé qué fue lo que quedó mal con la configuración porque ya no pude más acceder a las carpetas y ni a las impresoras de Linux desde Windows. Intenté un montón de configuraciones de versiones anteriores de Ubuntu y ninguna me funcionó.

Hasta que encontré este lugar y quedó de nuevo trabajando, cambiando la instrucción (de acuerdo al ejemplo, solo cambiando la ruta de mis carpetas):

chown -R nobody:nogroup /samba/anonymous por chown -R serverlinux:nogroup /MiRed/MisCarpetas

ya que al principio probé con nobody, podía accesar a carpetas y archivos pero no grabar.

Solo me queda reconfigurar las impresoras que aún lo tengo pendiente, por ahora la impresora la tengo instalada en modo compartida en un equipo con Windows, a ver si pueden escribir un pequeño manual para saber cómo configurarlas. Además, la manera de restringir a usuarios a ciertas carpetas es la parte que también explican aqui pero que aun no lo he probado.

Quiero comentar también que en Linux soy novato y esta explicación fue muy entendible a comparación de otros que encontré ne la web.

Muchas gracias.



By: Aure

Hola a [email protected]!!

Por alguna razón de un día para otro, me volvió a dar problemas de conexión. Lo que haré ahora es hacer una instalación limpia de Ubuntu 16.04 y a ver si con eso se resuelve, porque lo que hice fue hacer actualización desde versión 14.04 a ésta nueva versión.

Ya les estaré contando, saludos.

By: Aure

El problema que encontré es que se desconecta del wifi sin razón alguna y no la configuración de Samba, al parecer es del mismo administrador del wifi de Ubuntu.

Buscando en internet, encontré que no nada más a mí me está pasando la desconexión y dieron una solución temporal que funciona y es la siguiente:

sudo service network-manager restart (fuente:

De ser posible, hacerlo varias veces hasta que se vuelva a reconectar. A mí, del todo no me conviene ya que tengo un sistema en red y a mis compañeros que se conectan a ella, a cada rato los "bota" del sistema.

Espero y se resuelva pronto esto por parte del equipo de Ubuntu o de plano instalar una versión anterior.



By: Martin 0105

after installing samba in anonymous configuration one major difficulty occured: I was able to create a subfolder from my Windows 10 desktop, but the subfolder does not have write permission and I cannot change the permission in Windows 10. Of course I can change the permissions on the server, but that is not really a good workaraound. What did I d wrong?

By: Martin 0105

What I did wrong was to install Windows 10 ...

As Admin on Windows 10, I was finally able to change permissions on the Anonymous folder and all subfolders. So it works fine.

By: obaino

excuse but I cannot find the link to download the vm image of this tutorial

By: till

Upper right corner, below the big red download icon.

By: Dirk

After trying the two gui's for configuring samba several times I waited to find time to try the manually config. With your tutorial it was that easy - why didn't I try earlier ;) Thanks!

By: ben1828

Thank you - a great help :)

By: KleinVuur

In the anonymous example if I create a new folder I automaticly get:

New Folder

New Folder (2)

New Folder (3)

New Folder (4)

I can drag and drop stuff..

By: Bogdan

I solved it by adding this to the anonymous share section :

force directory mode = 0775

I also use Windows 10 x64 and Ubuntu 16.04 x32

By: Lukman Suprayitno

I can share directory anonymous and create folder, but when I create another sub folder inside the folder, or copying folder that contains files and sub-folders it gives me error permission. what should i do?

By: Harry

"Now you can access the Ubuntu sharing in Windows by entering "\\server1" in the windows search field of the menu or use the network browser of the Windows file explorer to connect to the share."

No I can't, Do I only have to modify the hosts file and nothing else? How do you make the network appear besides your computer on the windows explorer sidebar?? If I run \\server1 I get a path not found error. Definetly there are missing steps here.

By: cmcanulty

I can't get it to work at all accessing other ubuntu 16.04 or windows 10

must be missing steps thank you

By: mike moller

 Hi Till - many thanks for this tutorial - it's given me a breakthrough after quite some hours struggling to find up to date info

I've implemented your section 2 for the anonymous server and it works fine with two different W10 systems able to see the anonymous folder and to read/write create sub-folders etc - in fact all working normally for my simple home based local network

BUT I've come unstuck when I've tried to use the same approach to work with another physical disk on the Linux/Samba machine. The disk is mounted (/media/a1000) on the linux side and I can do all the things I need. However in W10 while I can see the mounted disk in File Explorer I can't progress beyond there and it gives me an Error about not having permission to access and telling me to contact my network administrator (a nice Catch 22 there as I am the said admin!!)

Have you any advice or "magic sauce" to ease me past this roadblock


cheers from New Zealand

By: ScriptDid

"> /etc/samba/smb.conf" is enough

By: Jum

Thank  you very much for your clear tutorial.

I've tried several, and yours is the first one that works flawless with easy and clear steps! 

By: Alfredo Peres

Worked for me, thanks!!

By: Antonely93


i must use this to intall # apt-get -f install

but have this error: /var/cache/apt/archives/liboxideqtcor0_1.21.5-0ubuntu0.16.04.1_amd64.deb

E: Sub-process /usr/bin/dpkg returned an error code (1)


How to fix?

By: Anisio Dgedge

I found it so usefull


By: Carlo Ranieri

Thank you, essential and precise. I have done the same configuration but when I work on the server I do not see the Netbio name =  UBUNTU, when I run the testparm. When I browse in Win 10 I do not see the server, UBUNTU. I connected the Anonymous and Secured folders to the Win 10 desktop. When I'm on an iMac-Linux workstation I can browse the WORKGROUP, the server, UBUNTU (linux), the 1571G50K server, (woprkstation win10). On the Win10 workstation, 1571g50k, before connecting the UBUNTU server, I could see, in Win10 network resources, the same 1571g50k workstation as a server. Now, on Win10 I can not see neither UBUNTU nor 1571G50K servers.Only 2 differences, apparently, my version of Samba is 4.3.11-Ubuntu and directories are in / home / samba /. Maybe you have an idea of why this thing happens? Thank you again...

By: thanks matge

Thank you very much, it works like a charm just follow the steps above, working both for shared and secured!!!!


By: edgar batz

gracias amigo por compartir tus conocimientos me sirvio mucho el tutorial para lo que necesitaba

sigue adelante gente asi necesitamos