How to implement SAMBA (SMB) file shares for Servers and Clients


Samba assists in providing shared access to files and printers across multiple networked machines. On the remote server, a CIFS client application can read, write, edit, and even delete files. The de facto CIFS standards are Microsoft implementations. So, what exactly is SMB? “Server Message Block” is the acronym for “Server Message Block.” It’s an IBM-developed file-sharing protocol that’s been around since the mid-1980s. If you’re troubleshooting, seek the application that claims to implement the SMB protocol, as it’s a protocol (an agreed-upon manner of communication between systems) rather than a specific software application. In this article, I will show you how to install Samba both on the server and client computer. Other guides can be found here: A-Z of Domain Name System: All you need to know about DNS/, and How to Install and Configure Postfix as a Send-Only SMTP Server/, also How to install Apache Tomcat on Ubuntu/, and How to install MariaDB on Ubuntu / and How to use container insights to get the full benefits of Azure Monitor for Azure Kubernetes workload/ and How to Install LAMP Stack on Ubuntu 18.04

The SMB protocol was created to allow machines on a local area network to read and write files to a remote host (LAN). "Shares" are the directories on distant hosts that are made available via SMB."Common Internet File System" is the acronym for "Common Internet File System." SMB has a dialect called CIFS. To put it another way, CIFS is a unique system.

Features of Samba

  • Samba can create file or printer shares.
  • Samba version 3.x can act as a WindowsNT domain controller.
  • Samba version 4.x can act as an Active Directory domain controller.
  • Samba version 4.x is available on most distributions.

We need to install samba:

Install samba:
$apt install samba
verify Samba is running:
$sudo systemctl status smbd

we would need to make a directory to enable us to share samba

$ mkdir /srv/smbshare

We can take a look at the main configuration file with the command.

$vim /etc/samba/smb.conf
sm.conf file

In the configuration file, there is a global section, the global section applies to the entire samba server, there is a workgroup name, and this is the same as a domain name amongst others. If we scroll down the configuration file, we will see other shares that are meant for other purposes. If on your own config file, you see a printer for example, that makes sure that any printer that is configured on the system is accessible as a samba share. And there are specific shares. But for the purpose of this article, we will add our own share and call it [smb share] and this is the label. It needs to be outlined to the left and needs to be indented. The minimum configuration for this specifies a comment.

smb share config

Let’s evaluate the configuration that we have just added to the smbshare with:


testparm accesses the configuration and it sends a warning signal if there is any issue.


Since there is no complain, then we didn’t make any syntax errors, we can proceed, and the dump file is shown below

systemctl enable --now smb

Add user Noah to a group

sudo useradd -M -d /samba/noah -s /usr/sbin/nologin -G sambashare noah

The following are the meanings of the useradd options:

-M: omits the creation of the user’s home directory. This directory will be manually created.
-d : Set the user’s home directory to /samba/noah with the -d option.
-s: /usr/sbin/nologin – prevents this user from accessing the shell.
-G: Add the user to the sambashare group using -G sambashare.

We need to create an smb password for the user:


Create an Admin user as well

sudo useradd -M -d /samba/users -s /usr/sbin/nologin -G smbshare sysadmin
sudo smbpasswd -a sysadmin
sudo smbpasswd -e sysadmin

Create a directory for users

sudo mkdir /samba/users

Set the owner of the directory to sysadmin and the sambashare be group owner:

sudo chown sysadmin:sambashare /samba/users

Give read and Write access to users

sudo chmod 2770 /samba/users

Further configuration of Samba share

sudo vim /etc/samba/smb.conf
sudo systemctl restart smbd
sudo systemctl restart nmbd

Using Linux to connect to a Samba Share

smbclient is a command-line utility that allows you to connect to Samba. Because the smbclient package isn’t pre-installed on most Linux distributions, you’ll need to use your distribution’s package manager to install it. Run the following commands on Ubuntu and Debian to install smbclient:

sudo apt install smbclient
Client running in a Linux VM from Azure Portal

our ip address can be gotten with: ip address show. Login to the client using the command:

smbclient -L -U noah
we successfully login

Mounting the Samba share 

On Linux, you must first install the cifs-utils package before mounting a Samba share. Run the following commands on Ubuntu and Debian:

$sudo apt install cifs-utils

Create a mount point next:

$sudo mkdir /mnt/smbmount

Mount the share with the command:

$sudo mount -t cifs -o username=username //samba_hostname_or_server_ip/sharename /mnt/smbmount

sudo mount -t cifs -o username=noah // /mnt/smbmount



We can actually connect to the smbshare we created using GUI as Gnome’s default file manager, Files, offers a built-in option for accessing Samba shares. To access use the following steps:

  1. Open Files and go to the sidebar and select “Other Locations.”
  2. Enter the Samba share’s address in the format smb:/samba hostname or server ip/sharename in “Connect to Server.”
  3. When you click “Connect,” you’ll see the following screen as shown below
  4. Select “Registered User”, enter the Samba username and password and click “Connect”
  5. The files on the Samba server will also show


You learned how to install the Samba server on Ubuntu 20.04, it can work with all other versions of Ubuntu as well and we built several types of shared and user folders in this article. We’ve also shown you how to use Linux to connect to the Samba server.

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x