Samba

Samba

Samba is a piece of software used to share directories over a network. Directories shared using samba appear as network folders on the file manager of computers that are on the same network.

Samba installation

samba can be installed easily using apt:

sudo apt-get install samba

Samba configuration

Samba is configured using the /etc/samba/smb.conf file

Here is an example configuration file that shares the directory /mnt/hdd/samba_shares, belonging to user myusername

[MY SHARED DIRECTORY]
  valid users = myusername
  writable = yes
  path = /mnt/hdd/samba_shares
  comment = My shared directory

Because permissions don't work the same way between Linux and Windows, the line valid users = myusername ensures the files can only be accessed by username. This option requires myusername to be a registered user of samba. This can be done with the following shell command:

sudo smbpasswd -a myusername

Here the password must match that of the unix account myusername. Once done, samba will prompt for username and passowrd anyone trying to access the shared folder from a remote location.

Multiple directories using the same properties (same valid users for example) can be shared as so:

[GLOBAL]
  valid users = myusername
  writable = yes

[MY SHARED DIRECTORY 1]
  path = /mnt/hdd/sambashares1
  comment = My first shared directory

[MY SHARED DIRECTORY 2]
  path = /mnt/hdd/sambashares2
  comment = My second shared directory