How to Install Samba on Ubuntu 20.04

Install Samba on Ubuntu 20.04

In this article, we will have explained the necessary steps to install and configure Samba on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Samba is a free and open-source re-implementation of the SMB/CIFS network file sharing protocol that allows end-users to access files, printers, and other shared resources.

Install Samba on Ubuntu 20.04

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

sudo apt update
sudo apt upgrade

Step 2. Installing Samba on Ubuntu system.

To install Samba, run the commands below:

sudo apt install samba

To verify if Samba services are running, run the commands below:

sudo systemctl status smbd

Step 3. Configuring Samba.

Now the first backup its default configuration file:

sudo cp /etc/samba/smb.conf{,.backup}

Next, open the Samba configuration file:

sudo nano /etc/samba/smb.conf

Add the following of the file:

======================= Global Settings =======================
## Browsing/Identification ###
# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = WORKGROUPnetbios name = linuxtips
   security = user
   proxy = no
   map to guest = bad user
#### Networking ####
# The specific set of interfaces / networks to bind to
# This can be either the interface name or an IP address/netmask;
# interface names are normally preferred
   interfaces = eth0
# Only bind to the named interfaces and/or networks; you must use the
# 'interfaces' option above to use this.
bind interfaces only = yes

#Most people will want "standalone server" or "member server".
#Running as "active directory domain controller" will require firstserver role = standalone server
obey pam restrictions = yes
#This boolean parameter controls whether Samba attempts to sync the Unix[public]
   path = /samba/public
   browseable = yes
   guest ok = yes
   guest only = yes
   read only = no
   force user = nobody
   force create mode = 0777
   force directory mode = 0777

Now that we have our new share configured, save it and restart Samba for it to take effect:

sudo systemctl restart nmbd

Step 4. Setting User Accounts and Connecting to Share.

Samba does not use system user accounts so we have to create samba accounts to share files with others. To create a user run the following command:

sudo smbpasswd -a yourusername

Step 5. Connecting to Share.

Open up the default file manager and click Connect to Server then enter:

Install Samba on Ubuntu 20.04

That’s all you need to do to install the Samba on Ubuntu 20.04 LTS Focal Fossa. I hope you find this quick tip helpful. For further reading on Samba, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.