Sometimes it would be convenient to share some files on your home network.
If you need to share files on your Linux host with Windows endpoints, Samba is an easy option.
This write-up is only risk-appropriate on a trusted network -- like the safe segment of my home network. Consider your environment before using this approach.
Assume that you want to share a directory called ~/Documents/eBooks on an Ubuntu host.
Install Samba.
sudo apt update
sudo apt upgrade -y
sudo apt install sambaSet up the Samba configuration file.
sudo vi /etc/samba/smb.confThen add the following to the file:
[shared]
comment = The eBook share
path = /home/<username>/Documents/eBooks
read only = yes
browsable = yesChange usershare allow guests = yes to:
usershare allow guests = noTurn off printer sharing if you don't need it. In the [print$] section, change browseable = yes to:
browseable = no
Give some thought to whether you want to have Unix and Samba passwords synchronized -- unix password sync = yes/no. See https://www.samba.org/samba/docs/using_samba/ch09.html.
Now that you have told Samba what to do, restart the Samba service so it will pick up your demands and tell the firewall to permit samba traffic.
sudo service smbd restart
sudo ufw allow sambaEven on a safe network, add a Samba password to each user account that will access the share.
sudo smbpasswd -a <username>