How to Install the Samba server on ubuntu server 20.04
Linux provides various options, such as Samba and NFS, to host a centralized storage server and share data across multiple computers.
Samba is a collection of open source applications that implement Server Message Block (SMB) and Common Internet File System (CIFS) protocols on Unix systems. This allows Samba to be accessible across different types of network system.
Installing the Samba server
Step 1 : Install the Samba server with the following command:
sudo apt-get update
sudo apt-get install samba -y
Step 2 : you can check the Samba version with the following command:
smbd --version
Step 3 : First, create a backup of the original configuration file:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.orignl
Step 4 : Next, open smb.conf and add the following lines to the Samba configuration to enable the sharing of public directories
sudo nano /etc/samba/smb.conf
[Public]
path = /var/samba/shares/public
browsable =yes
writable = yes
guest ok = yes
read only = no
create mask = 644
Step 5 : Next, we need to create a shared directory. Change the directory permissions to make it world writable:
sudo mkdir -p /var/samba/shares/public
sudo chmod 777 /var/samba/shares/public
Step 6 : Restart the Samba service for the changes to take effect:
sudo service smbd restart
Step 7 : Now you can access this Samba share on the Windows/Mac client. You should see the shared directory, Public, as follows:
Adding users to the Samba server
We installed the Samba server and created a public share accessible to everyone. Next, we will add authentication to the Samba server and password protect shared directories.
Step 8 : Create a new user account. Change smbuser to your desired username:
sudo useradd -d /home/smbuser -s /sbin/nologin smbuser
Step 9 : Now, we need to allocate a Samba password to this new user:
sudo smbpasswd -a smbuser
Step 10 : Create a shared directory for this user and change its ownership:
sudo mkdir -p /var/samba/shares/smbuser
sudo chown smbuser:smbuser /var/samba/shares/smbuser
Step 11 : Next, edit the Samba configuration to add the preceding share:
[Private]
path = /var/samba/shares/smbuser
browsable = yes
writable = yes
valid users = smbuser
Step 12 : Save the changes to the configuration file and reload the Samba server:
sudo service smbd reload
Step 13 : Now, check in Finder. You should see the new shared directory.