How to Install Samba on Ubuntu Server 16.04

In this tutorial we are going to learn how to install samba share server on Ubuntu Server 16.04. After Completing This tutorial you should be able to configure your Ubuntu Server as a file server and share files with the Microsoft Windows Operating System.

Ubuntu samba is a software package comes with Ubuntu Linux, which allows you to set up and configure your Ubuntu Server as a File server And allow you to share files with Microsoft windows via SMB Protocol.

First, we will install and configure samba on Ubuntu server 16.04 and then we will learn how to mount the samba share on Microsoft windows 7.

Install Samba Server On Ubuntu Server 16.04

We can Install Samba server on Ubuntu 16.04 using apt-get install command. This is same for older versions, including Ubuntu 14.04 and Ubuntu 12.04.

First Update the apt source list, then install the samba server.

sudo apt-get update

sudo apt-get install samba

install the samba server in ubuntu 16.04
install the samba server in ubuntu

Start Samba Server on Ubuntu 16.04

The Ubuntu Samba server should start automatically on Ubuntu After the installation finished, But if the samba is not running, you can start using init.d script.

sudo /etc/init.d/samba start

To view the samba server status, execute.

sudo /etc/init.d/samba status

You can also run the netstat command to make sure that the Ubuntu samba server is running on port  139 and 445.

sudo netstat -tulnp | grep smbd

ubuntu samba port

Ubuntu Samba Main Configuration file

Ubuntu Samba Main Configuration file is /etc/samba/smb.conf file. One important parameter in the main configuration file is workgroup. Name of the workgroup should match with the workgroup use in your Microsoft Windows Clients (Most of the time it is workgroup = WORKGROUP).

Create Samba user and setup Samba Password

We need a username and password to access samba share from a remote computer. For this tutorial I am going to create a new user called smbuser to access the samba share from windows 7.

sudo adduser smbuser

Then set up samba password for the smbuser using the smbpasswd command (We cannot use the standard Linux password to access a samba share).

sudo smbpasswd -a smbuser

Setup Samba Share

Now lets see how to share files on our Ubuntu server with Microsoft windows using the samba server.

I am going to create a new folder called winshare inside the /var folder and mount the /var/winshare folder on Windows 7. You can use any existing Directory if you want.

First, create the winshare directory using the mkdir command.

sudo mkdir /var/winshare

Set the file permission and also Make smbuser the owner of the /var/winshare directory using the chown command.

sudo chmod 755 /var/winshare/

sudo chown smbuser /var/winshare

Then add Following configurations to  the /etc/samba/smb.conf file.

[winshare]

path=/var/winshare

browseable = yes

read only = no

valid user=smbuser

Save the smb.conf file and reload the samba Configuration file.

sudo /etc/init.d/samba reload

Mount Ubuntu Samba share on Windows 7

Now we can mount the samba share on Windows 7.

To mount samba share on windows 7, Go to My Computer and Click on Map Network Drive Button.

map network drive windows 7

Then, Select a Drive letter and type \\server-ip\share-name in the folder path. For example.

\\192.168.1.10\winshare

mount ubuntu samba share on windows 7

You will be prompted for the username and password. Use the samba user and password we created and Click ok to mount the samba share.

So that is how we setup basic samba share on ubuntu server 16.04. You can refer to the man page of the smb.conf file For more advanced samba configuration options.

man 5 smb.conf

Once you know the basic setup, you can play with more advanced options.