Install Samba Server and Configure On Ubuntu 20.04/19.10

We can easily install and configure the samba server in ubuntu. We will need to add a samba user in ubuntu. In a similar way, you can install a samba server on ubuntu 18.04.

Install Samba Server and Configure On Ubuntu 20.04/19.10 

  1. We can simply use the below command to install samba on ubuntu. No need to add any repository for this. So, run the following commands. 
sudo apt update
sudo apt install samba

Check Out: How To Configure Samba Server For File Sharing On CentOS 7

2. You can find the samba location using the below command. 

ubuntu@ubuntu:~$ whereis samba
samba: /usr/sbin/samba /usr/lib/x86_64-linux-gnu/samba /etc/samba /usr/share/samba /usr/share/man/man8/samba.8.gz /usr/share/man/man7/samba.7.gz

3. Now we need to start and enable the samba service using the following commands. 

sudo systemctl start smbd && sudo systemctl enable smbd

Check the Samba service is running or not.

ubuntu@ubuntu:~$ sudo systemctl status smbd
● smbd.service - Samba SMB Daemon
Loaded: loaded (/lib/systemd/system/smbd.service; enabled; vendor preset: >
Active: active (running) since Mon 2020-08-03 09:39:39 PDT; 3min 13s ago
Docs: man:smbd(8)
Main PID: 4311 (smbd)
Status: "smbd: ready to serve connections..."
Tasks: 4 (limit: 2285)
Memory: 14.4M

Configure Samba Server On Ubuntu:

Once you have checked everything is working perfectly. it’s time to configure the samba server. We can check the samba configuration file located at /etc/samba/smb.conf

Check Out: Solve No WiFi Driver Adaptor Found In Ubuntu 18.04

  1. First of all, create a backup of the original file and we have also created a directory at user profile location which we will share later. 
sudo cp -rfvp /etc/samba/smb.conf /etc/samba/smb.conf-back
sudo mkdir sambadata

2. Open the Samba smb.conf file and configure the samba share with the below code.

sudo vim /etc/samba/smb.conf

comment = Users profiles
path = /home/ubuntu/sambadata
read only = no
browseable = yes

We can also check the samba configuration file for any errors before restarting the service. Use the below command to test the configuration.

ubuntu@ubuntu:~$ sudo testparm
Load smb config files from /etc/samba/smb.conf
Loaded services file OK.

If you see the loaded services fuel “OK” it means there’s no error in the file.  we can also use this command sudo testparm /etc/samba/smb.conf as well. This will also give you the same output.

Check Out: Install Advanced Intrusion Detection Environment (AIDE) On CentOS 7

3. Save the file and restart the service. We need to allow the samba service in the firewall rules using the following commands. 

ubuntu@ubuntu:~$ sudo systemctl restart smbd
ubuntu@ubuntu:~$ sudo ufw allow samba
Rules updated
Rules updated (v6) 

We can also check the listening port of the samba service. 

sudo netstat -tnlp | grep smbd

Set a Password For Samba User:

We will have to set a samba password for our user because samba doesn’t use the system account password. User must be system account else it won’t work. 

ubuntu@ubuntu:~$ sudo useradd usrsmb
ubuntu@ubuntu:~$ sudo smbpasswd -a usrsmb
New SMB password:
Retype new SMB password:
Added user usrsmb.

Now access the samba share folder using the below command. 


On your Ubuntu machine, Put the Address and click on “Connect“.   

samba configure ubuntu

Once you connect the server, you will see a window like shown below and we need to put the “username” and “password” then “connect” it.

ubuntu 18.04 samba server

Now you can see, I’m able to access the sambadata folder. 

add samba user ubuntu

That’s it. Samba add user ubuntu server 18.04

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

Leave a comment