How To Set Up a Samba Share on Ubuntu 16.04

Prerequisites

Update the System

sudo apt-get update

Install Samba

sudo apt-get install samba
sudo systemctl stop nmbd.service
sudo systemctl disable nmbd.service
ubuntu@Sajid:~$ sudo systemctl disable nmbd.service
nmbd.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install disable nmbd
insserv: warning: current start runlevel(s) (empty) of script `nmbd' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `nmbd' overrides LSB defaults (0 1 6).
sudo systemctl stop smbd.service
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.orig
ip link
ubuntu@Sajid:~$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 02:f8:7d:b9:7b:dc brd ff:ff:ff:ff:ff:ff
sudo apt-get install nano
sudo nano /etc/samba/smb.conf
[global]
server string = samba_server
server role = standalone server
interfaces = lo your_network_interface
bind interfaces only = yes
disable netbios = yes
smb ports = 445
log file = /var/log/samba/smb.log
max log size = 10000
testparm
Load smb config files from /etc/samba/smb.conf
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
#Global parameters
[global]
server string = samba_server
interfaces = lo your_network_interface
bind interfaces only = Yes
server role = standalone server
log file = /var/log/samba/smb.log
max log size = 10000
smb ports = 445
disable netbios = Yes
idmap config * : backend = tdb

Adding Users

sudo mkdir /samba/
sudo chown :sambashare /samba/
sudo mkdir /samba/paul
sudo adduser --home /samba/paul --no-create-home --shell /usr/sbin/nologin --ingroup sambashare paul
sudo chown paul:sambashare /samba/paul/
sudo chmod 2770 /samba/paul/
sudo smbpasswd -a paul
sudo smbpasswd -e paul
sudo mkdir /samba/everyone
sudo adduser --home /samba/everyone --no-create-home --shell /usr/sbin/nologin --ingroup sambashare adminsudo chown admin:sambashare /samba/everyone/
sudo chmod 2770 /samba/everyone/
sudo smbpasswd -a admin
sudo smbpasswd -e admin
sudo groupadd admins
sudo usermod -G admins admin

Configuring the Samba Shares

sudo nano /etc/samba/smb.conf
[paul]
path = /samba/paul
browseable = no
read only = no
force create mode = 0660
force directory mode = 2770
valid users = paul @admins
[everyone]
path = /samba/everyone
browseable = yes
read only = no
force create mode = 0660
force directory mode = 2770
valid users = @sambashare @admins
[global]
server string = samba_server
server role = standalone server
interfaces = lo your_network_interface
bind interfaces only = yes
disable netbios = yes
smb ports = 445
log file = /var/log/samba/smb.log
max log size = 10000
[paul]
path = /samba/paul
browseable = no
read only = no
force create mode = 0660
force directory mode = 2770
valid users = paul @admins
[everyone]
path = /samba/everyone
browseable = yes
read only = no
force create mode = 0660
force directory mode = 2770
valid users = @sambashare @admins
testparm
sudo systemctl start smbd.service

Accessing Your Samba Shared Server

Linux ?The Command Line

sudo apt-get update
sudo apt-get install smbclient
sudo yum update
sudo yum install samba-client
smbclient //YourServerIP/share -U username
smbclient //YourServerIP/paul -U paul
smbclient //YourServerIP/everyone -U paul
smb: \> mkdir direc
smb: \> ls

Linux ?KDE with Dolphin

Windows 10 ?The Command Line

C:\> net use drive_letter \\YourServerIP\share
C:\> net use F: \\YourServerIP\paul

Windows 10 ?Desktop

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store