In this tutorial, we will show you how to install Samba on Ubuntu 20.04 LTS. For those of you who didn’t know, Samba is a free software re-implementation or open-source implementation of the SMB/CIFS protocol that allows users to access shared files printers, and other network resources.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Samba on Ubuntu 20.04 (Focal Fossa). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
- A server running one of the following operating systems: Ubuntu 20.04, 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install Samba on Ubuntu 20.04 LTS Focal Fossa
Step 1. First, make sure that all your system packages are up-to-date by running the following
apt commands in the terminal.
sudo apt update sudo apt upgrade
Step 2. Configure Host File.
We need to add Ubuntu 20.04 LTS to the Windows host file. To do this, run the following command in Windows:
You need to add the local entry for the Ubuntu to be referenced by the named ubuntu2004 and save it:
192.168.1.3 ubuntu2004.localhost ubuntu2004
Then, run the commands below and type the IP with the hostname of Windows, save the file, and exit:
sudo nano /etc/hosts
Once done, run the following commands in Windows with administrative privilege:
netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes netsh advfirewall firewall set rule group="Network Discovery" new enable=Yes
Step 3. Installing Samba on Ubuntu 20.04.
Run the following command in the terminal to install Samba on the Ubuntu system:
sudo apt install samba samba-common-bin
To verify if Samba services are running, run the commands below:
sudo systemctl status smbd
Step 4. Configure Samba Public share.
Run the following command to open the Samba configuration:
sudo nano /etc/samba/smb.conf
Add the following line:
======================= Global Settings ======================= [global] ## Browsing/Identification ### # Change this to the workgroup/NT-domain name your Samba server will part of workgroup = WORKGROUPnetbios name = ubuntu2004 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 = 127.0.0.0/8 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
Restart Samba daemon after making the changes:
sudo systemctl restart smbd
Next, you need to create a public folder where everyone should have access:
sudo mkdir -p /samba/public
Once successfully, restart the Samba server. You can see the shared folder in Windows 10 or whatever Windows you are using.
Step 5. Configure Firewall.
If you have an active firewall, run:
sudo ufw allow 'Samba'
Congratulations! You have successfully installed Samba. Thanks for using this tutorial for installing Samba on your Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you check the official Samba website.