Samba on Linux

Updated 08-Nov-2023

If one wants to say, stream video or music from a file system, but using a different computer. This is not difficult with Samba (aka CIFS) on Linux. Using apps like VLC on Google TV will allow connectivity to the drive over the network.

Install and Configure SMB

sudo apt install samba
sudo nano /etc/samba/smb.conf
  • After WORKGROUP, add:

force user = folderuser if you want to require a single user access, such as to personal directories

  • Uncomment the hosts allow section to only the local subnet
  • Comment out the [homes] home directory section, unless using it


Make the following settings changes:

  • browsable = yes
  • guest ok = yes
  • printable = yes

At the end of the file, add:

[directory share name]
path = /media/directory
writeable = yes
valid users = username1, username2
read only = no
browsable = yes

Note that changing writeable and read only to no and yes, respectively, make it so.

Manual USB drive mapping (if needed)

Ensure that path (above) and (below) do match. This code works for a single external USB drive, formatted NTFS, and found at \dev\sdb1:

sudo mount -t ntfs-3g /dev/sdb1 /media/directory -o uid=1000

A better approach is to mount in fstab:

  • Install ntfs-3g

sudo apt install ntfs-3g

  • Find the disk with fdisk

fdisk -l

Find the UUID value for the disk (usually sdb1)

sudo blkid /dev/sdb1

Create the mount directory

sudo mkdir /media/directory

Add to fstab:

UUID="0123456789ABCDEF" /media/video/ ntfs-3g rw,uid=1000,gid=1000,dmask=0002,fmask=0003 0 0

Enable / Restart smbd service

sudo service smbd restart

Enable Samba on whichever firewall one has, such as:

sudo ufw allow samba

Add Samba users

Samba does not use the Linux user accounts, so one must create users and passwords individually.

sudo smbpasswd -a username

Known issue on Nemo

  • Sometimes there is an error message on trying to connect with Nemo to a share that it previously connected to. This is an open bug on Github. Use killall nemo then restart and it should work again.