In this post I will explain how to install a shared linux directory on a local network using samba. This drive can then be accessed by Windows, iOS, android, etc. There are two ways you can do this, either by specifying a user, or by specifying a group. I recommend the second approach because it is the more general case and it fits my usage.

Requirements

A linux computer, debian based.

Procedure

First install samba

sudo apt-get install samba

add a user

sudo useradd [user]

set a password for this user

sudo smbpasswd -a [user]

Make a new folder in any location you choose, and give it a name, such as Share

cd ~/Desktop/
mkdir Share

Make a group and give it a name, too

sudo groupadd [group]

Add two users to the group, the user you just made and the user name of the computer the shared folder is on

sudo usermod -a -G [group] [user]
sudo usermod -a -G [group] [computer_username]

This is two avoid file permission problems if you edit the file from the computer that has the shared folder. What we will do is give the permission to the group instead of giving it to a user, as covered by some posts such as 1 or 2. Now open the samba configuration file

sudo vi /etc/samba/smb.conf

and put the following at the bottom of the file

[Share]
​   path = /home/Desktop/Share
​   read only = no
​   writeable = yes
​   browseable = yes
​   valid users = @[group]
​   create mask = 0660 
​   directory mask = 0770

and restart the service so that changes take effect

sudo service smbd restart

Now you can connect to the service. Take note of the ip address of the device that has the Share folder by, for example, running this command in its terminal

ip a | grep inet

Now you can connect to it from Windows, Android, or iPad.


References