Skip to content

Setting up Samba

Install samba

First install Samba package. From Terminal enter:

sudo apt install samba

Configure Samba File Server

Append the samba configuration file located in /etc/samba/smb.conf with below lines.

Restricted share

What is Restricted share

  • Share only for specific group
  • Only accessible if correct username and password is provided
/etc/samba/smb.conf
[SHARE-NAME]
    comment = ANY-COMMENT
    # allows only users from that group to access this path
    valid users = @GROUPNAME
    path = /PATH/TO/SHARE/DIR/
    read only = no
    browseable = yes

Make sure to update values to your server directory to be used.

Breakdown of values to be updated..
Value Description
SHARE-NAME Share name that is visible to the Network. Use something that describes the share
ANY-COMMENT Comments for better understanding. Can be anything
@GROUPNAME Used to restrict the share to specific group in linux.
/PATH/TO/SHARE/DIR/ Absolete Path to directory that should be shared

Guest Share

What is Guest Share

  • Anyone can access this share.
  • This share will be visible without username or password.
  • If the user enters wrong username and password this share will be visible.
/etc/samba/smb.conf
[guest]
comment = Guest File Share
path = /PATH/TO/SHARE/DIR/ # change the path to match your guest FS
read only = no
browseable = yes
guest ok = yes
guest only = yes
writeable = yes

Create the directory

Samba is now configured, the directory needs to be created and the permissions changed.

sudo mkdir -p /PATH/TO/SHARE/DIR/
sudo chown nobody:nogroup /PATH/TO/SHARE/DIR/

The -p switch tells mkdir to create the entire directory tree if it doesn’t already exist.

Enable the new configuration

Restart the Samba services to enable the new configuration by running the following command:

sudo systemctl restart smbd.service nmbd.service

Advanced Setup

This will get you a basic samba setup to share files for more advanced setup refer