You are on page 1of 7

Samba Setup on Ubuntu 16.04 / 17.10 / 18.

04 with
Windows Systems

February 27, 2018

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

Windows IP address =========================>

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

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

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

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

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 definition ================================

workgroup = WORKGROUP
server string = Samba Server %v
netbios name = ubuntu1604
security = user
map to guest = bad user
name resolve order = bcast host
dns proxy = no
bind interfaces only = yes

#============================ Share Definitions ==============================

path = /samba/public
writable = yes
guest ok = yes
guest only = yes
read only = no
create mode = 0777
directory mode = 0777
force user = nobody

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…

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

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

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….


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

You may also like the post below: