Samba shares are used when you want to share data within a local network to a group of people.
The first step is to install Samba
sudo apt install samba
sudo pacman -S samba (arch)
sudo smbpasswd -a <username>
First create a folder say test in /home/user to test samba shares. It can be done by :
- mkdir test
- chmod -R 664 test (chmod is used to change folder permissions)
- cd test
- touch {1..10} (creating few files to check stuff)
Now after doing that we need to edit the /etc/samba/smb.conf file
first make a safe backup by
cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
lets name the share as testshare
[global]
server role = standalone server
[testshare]
path = /home/user/test
read only = no
browsable = yes
valid users = user @admins
force user = usergroupname
force group = usergroupname
these are the basic option you can edit them to your hearts content
few options are
(in global)
map to guest = bad user
usershare allow guests = yes (guest)
hosts allow = 192.168.0.0/16 (ip range)
hosts deny = 0.0.0.0/0
(in share)
directory mask = 2775 (file permissions)
force directory mode = 2775
directory security mask = 2775
force directory security mode = 2775
force create mode = 2775
now to allow users use the command
sudo smbpasswd
now go to /etc/sambaand execute the following command to test samba shares
testparm
if the output has a error check for spelling mistakes, the ideal output should be something like
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section “[testshare]”
Processing section “[media]”
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definition
(press enter)
Global parameters
[global]
server role = standalone server
idmap config * : backend = tdb
[testshare]
force group = usergroupname
force user = user
path = /home/user/test
read only = No
valid users = user @admins
if everything works go and start your share
sudo systemctl start smbd ( or sudo service smbd start)
sudo ufw allow Samba
sudo ufw reload
if everything works perfectly check your ip using ifconfig and connect to the samba share using a file explorer which supports it.
smb://ipaddress/sambashare
