SAMBA share on Ubuntu

Ettienne LouwEttienne Louw
2 min read

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

The following should be its output:

samba: /usr/sbin/samba /usr/lib/samba /etc/samba /usr/share/samba /usr/share/man/man7/samba.7.gz /usr/share/man/man8/samba.8.gz

2. Setting up Samba

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

mkdir /home/<username>/sambashare/

The command above creates a new folder sambashare in our home directory which we will share later.

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:

[ShareName]  
    comment = My Shared Folder  
    path = /path/to/your/shared\_folder  
    read only = no  
    browsable = yes  
    guest ok = yes # Set to 'no' for authenticated access only*  
    writable = yes

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 User Accounts and Connecting to Share

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
  • Username used must belong to a system account, else it won’t save.
\\192.168.1.100\ShareName

To mount your newly created shared volume refer to this article Mount a share on Ubuntu

0
Subscribe to my newsletter

Read articles from Ettienne Louw directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ettienne Louw
Ettienne Louw