Setup Samba on ubuntu server 22.04 LTS
Back to Home / Back to Notes

Setup Samba on ubuntu server 22.04 LTS

Summary:

1 - Installing Samba

2 - Setting up Samba

3 - Setting up users

4 - Access the share

Tutorials used as reference:

Ubuntu - Setup Samba

1 - Installing Samba

To install Samba, we run:

sudo apt update sudo apt install samba

We can check if the installation was successful by running:

whereis samba



2 - Setting up Samba

Now that Samba is installed, we need to create a directory for it to share:

mkdir /home/username/sambashare/

The configuration file for Samba is located at /etc/samba/smb.conf. To add the new directory as a share, we edit the file by running:

sudo nano /etc/samba/smb.conf

At the bottom of the file, add the following lines:

[sambashare]
comment = Samba on Ubuntu
path = /home/username/sambashare
read only = no
browsable = yes

Then press Ctrl-O to save and Ctrl-X to exit from the nano text editor.

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

sudo service smbd restart

Update the firewall rules to allow Samba traffic:

sudo ufw allow samba

3 - Setting up users

Since Samba doesn’t use the system account password, we need to set up a Samba password for our user account:

sudo smbpasswd -a username

Note: Username used must belong to a system account, else it won’t save.

If we want other users to access, we have to create them:

sudo useradd username1

After we filled their information, we give them a Samba password:

sudo smbpasswd -a username

4 - Access the share

On Windows, open up File Manager and edit the file path to:

\\192.168.1.6\sambashare