Samba Setup on Ubuntu 16.04 | 17.10 | 18.04 with Windows Systems

When you have both Windows and Ubuntu machines on the same network, you can use Samba + SMB/CIFS to enable files and printer sharing… This brief tutorial is going to show students and new users how to get that done..

Samba is an open source software that provides seamless file and print services to SMB/CIFS clients… Samba enables Linux systems, including Ubuntu to share files with Windows systems, including Windows 10…

For this tutorial to work, you may want to configure both the Windows and Ubuntu machines on the same subnet. This means they should be able to communicate over the network… For this tutorial, we’re going to be using a network…

The Windows machine will have IP address and the Linux machine

Both machine will also be in the same local workgroup. You can name the workgroup whatever you want, but for this post, our workgroup will be the default Windows workgroup called WORKGROUP

Windows IP address =========================>
Ubuntu IP address ==========================>
Workgroup Name ===========================> WORKGROUP

Both the Windows and Ubuntu machines will be member of the local workgroup called WORKGROUP

Step 1: Identify Windows Workgroup

To find out which Workgroup Windows machine belongs, open the command prompts and type the commands below

net config workstation

When you run the commands above, you should see your current Workstation domain name for the computer… usually called WORKGROUP

windows computer workgroup

Step 2: Add Ubuntu Machine IP to Windows Host File.

If you don’t have a DNS system in place and you want to reference each system by their names, you’ll want to add their names in the local host file on each machine.. For Windows system, open the commands prompt as administrator and run the commands below

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

Then add the local entry for the Ubuntu machine to be referenced by the named ubuntu16.04            ubuntu1604.localhost           ubuntu1604

Save your changes and you’re done.

To add Windows system name to Ubuntu host file, press Ctrl — Alt –T on your keyboard to open the command terminal… then run the commands below:

sudo nano /etc/hosts

Then type the IP with hostname for Windows machine… and save the file..


To make file sharing possible, that feature must be enabled on Windows systems… To enable it, run the commands prompt as administrator and run the commands below

Then run the commands below to enable filesharing and network discovery.

netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes
netsh advfirewall firewall set rule group="Network Discovery" new enable=Yes

Step 4: Install Samba on Ubuntu

At this point, Windows and Ubuntu systems should be member of the same workgroup and both systems have entries in their local host file to reference the other by name.

Next, logon on to the Ubuntu machine to install Samba. To install Samba, run the commands below.

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

After installing Samba, go and config Samba.

Step 5: Configure Samba Public share

Now that Samba is installed, run the commands below to backup its default configuration file.

sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bak

Next, open Samba configuration file by running the commands below.

sudo nano /etc/samba/smb.conf

Copy and paste the content below into the file and save… this will create a share named Public where everyone will have access on the Ubuntu to it.

======================= Global Settings =======================
## Browsing/Identification ###
# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = WORKGROUP
   netbios name = ubuntu2004
   security = user
   proxy = no
   map to guest = bad user
#### Networking ####
# The specific set of interfaces / networks to bind to
# This can be either the interface name or an IP address/netmask;
# interface names are normally preferred
   interfaces = eth0

# Only bind to the named interfaces and/or networks; you must use the
# 'interfaces' option above to use this.
bind interfaces only = yes

#Most people will want "standalone server" or "member server".
#Running as "active directory domain controller" will require first

server role = standalone server
obey pam restrictions = yes

#This boolean parameter controls whether Samba attempts to sync the Unix
   path = /samba/public
   browseable = yes
   guest ok = yes
   guest only = yes
   read only = no
   force user = nobody
   force create mode = 0777
   force directory mode = 0777

Save your change

Step 6: Create the Public folder to share

Next, create the public folder where everyone should have access to as defined in Samba configuration above…

sudo mkdir -p /samba/public

Set the permissions so that everyone can read and write to it.

sudo chown -R nobody:nogroup /samba/public
sudo chmod -R 0775 /samba/public

Restart Samba and open Windows File Explorer to view the shared location on Ubuntu

sudo service smbd restart

Now go to your Windows machine and you should see the shared Public folder on Ubuntu from when you browse File Manager as shown below…

ubuntu samba sharing

Everyone should have access there.

Step 6: Configure Samba Private Share

Now you know how to create Samba public shares, let’s go and create private and protected shares. Only users that are member of the approved group will be able to access the secure location with passwords.

First create a samba group called smbgroup for the share.. only members will have access. To create a groups in Ubuntu, run the commands below.

sudo addgroup smbgroup

Then add a user to the group by running the commands below

sudo usermod -aG smbgroup richard

Finally, all users who need to access a protected samba share will need to type a password. To add a user to samba password database, run the commands below for each user.

sudo smbpasswd -a richard

The user will be prompted to enter and confirm a password. This password will be used to access the protected samba shares.

Next, go and create a protected share in the /samba directory.

sudo mkdir -p /samba/protected

Then give only root and members group access to this share.

cd /samba/
sudo chown -R root:smbgroup protected
sudo chmod -R 0770 protected

When you’re done creating the protected share, go and share it in the smb.conf file.

sudo nano /etc/samba/smb.conf

Then add configuration block below into smb.conf file just below the one above

  path = /samba/protected
  valid users = @smbgroup
  guest ok = no
  writable = yes
  browsable = yes

Save your changes and you’re done.

Restart Samba and test your changes.

sudo service smbd restart

You should now see two folders… one is protected

ubuntu sharing windows 10

Many more shares can be defined using the format above.

Only member of the smbgroup will be able to access the Protected area…

You could map the drive in Windows for easy access….

ubuntu samba shares


ubuntu samba windows

That’s it! This is how to setup Samba to share files with Ubuntu

You may also like the post below:


  1. ” Step 5: Configure Samba Public share
    .. sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
    ———————————————————- ‘
    Instead of ‘mv’ it should be ‘cp’ else how come –
    ‘ sudo nano /etc/samba/smb.conf’ ?

    1. He wants to create a new smb.conf from scratch, rather than modifying the existing default configuration.

      1. Using 18.04LTS Ubuntu, I had issues with the provided configuration file. Instead, I actually left the original config in place, skimmed through it, and only added the public/private sections to the bottom of the default configuration file. Then followed the remaining public/private setups, and they worked perfectly. Thanks for the guide!



  2. When i do the same config to add custom directory to share definations.. Windows says “Windows cannot access share”

    1. I’m having the same problems. Anyone else have these issues?

      1. Look into this as a possible:
        I had to issue from Ubuntu: ‘sudo ufw allow Samba’ in order to get Windows file explorer to access the Ubuntu shared folders ‘Public and Protected’

  3. thanks alot thanks to you i found where my mistake was. best step by step tutorial so far.

  4. Wonderful tutorial, thank you very much. There isn’t enough appreciation on the internet for such detailed and concise guide.

  5. I had to issue from Ubuntu: ‘sudo ufw allow Samba’ in order to get Windows file explorer to access the Ubuntu shared folders ‘Public and Protected’

  6. Completed step 6 butt ubuntu doesn’t even appear in networks, what im i doing wrong?

    1. Please see my comments below. I had the same problem with you but it’s resolved.

  7. This whole tutorial is bunk! Doesn’t work. Don’t waste your time.

    1. It did not work for you (maybe you made a mistake) but it might have worked for others – it worked for me :-). So please don’t use phrases like ‘Don’t waste your time’. It’s bad manners…

      1. Worked for me on Ubuntu 18.04LTS, using a Windows Workgroup, and Windows 10. Great guide.

  8. so many samba writeups none of them work!

    finally! SO many thanks.

  9. Nothing worked (I could not even see my linux machine on the windows network) until I issued these two commands:
    sudo systemctl enable smb.service
    sudo systemctl enable nmb.service
    Then restarted the two services:
    sudo systemctl restart nmb.service
    sudo systemctl restart smb.service

    I equally allowed samba through my firewall:
    sudo firewall-cmd –permanent –add-service=samba –zone=public

  10. Excelent. Thank you.

  11. Oh well, I thought a Linux home server was a good idea. I tried everything here and still nothing. I guess after years of trying to get a handle on Linux I’ll just stick to Microsoft products.

  12. thnk you very match its good tut help me a lot 🙂 😉

  13. the 2 netsh commands in windows doesn”t work on my computer. It just tells me, “no rules match the specified criteria” . Does anybody know a solution for this problem?

    1. @erik yes you can make it manual search for those services and enabled in windows firewall”File and Printer Sharing” and “Network Discovery”

  14. Still didn’t show how to enable the printer-share in Ubuntu, though creating share folders instruction is clear. Can you or some else please shoe me.

  15. Thank you! Excellent step by step instructions for a beginner like me!

  16. Christian Raynor

    I tried everything, ran through this multiple times – didnt work

  17. wITH 18..04 WINDOWS CAN ACCESS UBUNTU if both use SMB1. But ubuntu 18 wants no parts of win 10, no way no how. If you have it working both ways with ubuntu 18.04 and windows 10 please share how u did it…[email protected] thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.