How to install and configure samba server in Ubuntu 16.04

Samba Server details
Operating system: ubuntu 16.04
Server IP Address:
Hostname :
Config file : /etc/samba/smb.cnf
Service : smb
Port no : 137,138,139,445

Samba client details
Operating system: Windows 7, 8 and 10

What is Samba Server ?
“Samba is an Open Source/Free Software suite that provides file and print services to SMB/CIFS clients.”
It provides an easy way to share directory over Linux And Windows environment.

Benefits of using Samba Server
File and printer sharing with MS Clients
Provides user Authentication and access
Name resolution
Support on various platform
Can act as a Domain controller

Packages uses for samba server
Samba -Use for samba server
smbclient – Use for samba client
samba-common – Commands which use in samba server and client

Component of samba server
testparm – This command is use to test the samba configuration file.
smbstatus – This command is use to check the current connection of samba client.
smbpasswd – This command is use to set the password of samba user.

Install package on samba server
sudo apt-get install samba smbclient samba-common

Check Installed package
sudo dpkg -l | grep samba

Backup default samba configuration
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

sudo vim.tiny /etc/samba/smb.conf

#Allow your network in host allow section to access shared directory
hosts allow = 127. 10.0.1.

Enable User home directory in samba configuration
#add below line in bottom of file or if already enabled make sure parameters are these
comment = Home Directories
browseable = no
read only = no
create mask = 0700
directory mask = 0700
valid users = %S
read only = no

Restart samba service
sudo service smbd restart

Run command to test the configuration file
sudo testperm

Create user in server
sudo adduser test1
sudo adduser test2

Set password for samba user
smbpasswd -a test1
smbpasswd -a test2

Browser your share from client machine
Go to Start -> Run -> \\serverip_address\username

Create directory and set permission for samba share
You can also create different directory and share with user.
sudo mkdir /data && sudo chmod 777 /data

sudo vim.tiny /etc/samba/smb.conf

##Add following lines at bottom of config##
comment = “Data shared Folder”
path = /data
browsable =yes
writable = yes
read only = no
valid users = test1,test2

Reload samba service
sudo service smbd reload

Browser your share from client machine
Go to Start -> Run -> \\serverip_address

Startup script for automount
net use z: \\server-address\userdirectory User_passowrd /USER:username
net use z: \\\test1 pass@123 /USER:test1

Login samba user on server
smbclient //localhost/test1 -U test1

Show current connected user

List of samba user
pdbedit -w –L

Delete samba user
smbpasswd -x username

Disable samba user
smbpasswd -d username

Leave a Reply

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