How to Install and configure Samba on ubuntu 20.04 LTS

Samba is a free & open-source file sharing application.A Samba file server enables file sharing across different operating systems over a network.It allows users to access shared files,printers and network resources.

Samba can be run on multiple platforms including Linux, Unix, OpenVMS, Windows and allows the user to interact with a windows client or server.

Install Samba Server

Update the System.

apt-get update

Install Samba server.

apt-get install samba

Start & Enable Samba Server.

systemctl start smbd
systemctl enable smbd

Check the status of Samba Server.

systemctl status smbd

Here is the command output.

Fig 1

 

Create a directory for samba share.

mkdir /home/user/share1
&
mkdir /home/user/share2

Give the following permissions for both directories.

chmod 777 /home/user/share1
&
chmod 777 /home/user/share2

Create User to access Samba share.

useradd user1
&
useradd user2

Set Samba password for both users .

smbpasswd -a user1
&
smbpasswd -a user2

Here is the command output.

Fig. 3

 

Open the samba configuration file.

vim /etc/samba/smb.conf

Provide the following lines.

[share1]
   path = /home/user/share1
   valid users = user1, user2
   read list = user2
   write list = user1
   browseable = yes

[share2]
   path = /home/user/share2
   valid users = user1, user2
   read list = user1
   write list = user2
   browseable = yes

Check configuration file.

testparm

Here is the command output.

Fig. 5

 

Restart the Samba Server

systemctl restart smbd

 

 

Testing

  • Go to other location.
  • Click on network.
  • There are two samba share folder.

Fig. 3

 

  • Click on Share1.
  • Click on Registered User.
  • Provide Username & password.
  • Click on Connect.

Fig. 6

 

  • Once we can successfully connected.
  • Now,We can create & share files.

Fig. 7

 

 

Leave a Reply

Your email address will not be published.