SMB
Setup guide for sharing files over a local network using Samba (SMB/CIFS) between Linux and other devices.
Server
-
Install
Install the SMB server package to enable file sharing.
Terminal window sudo apt update && sudo apt install samba -y -
Set SMB password
Samba uses its own password database. It must be set manually, even if it’s the same as your login password.
Terminal window sudo smbpasswd -a {{USERNAME_VAR}}Enable the user (usually automatic, but safe to ensure):
Terminal window sudo smbpasswd -e {{USERNAME_VAR}} -
smb.conf
Terminal window sudo nano /etc/samba/smb.conf/etc/samba/smb.conf [shared]path = {{SMB_SHARE_VAR}}read only = nobrowsable = yesguest ok = no -
Restart service
Terminal window sudo systemctl restart smbdOptionally enable on boot:
Terminal window sudo systemctl enable smbd -
Allow through firewall (optional)
Allow access for SMB traffic.
Terminal window sudo ufw allow samba
Client
-
Access share
smb://{{SERVER_IP_VAR}}/sharedOr using hostname (if mDNS/Avahi is working):
smb://{{HOSTNAME_VAR}}.local/sharedNotes:
- Replace
sharedwith your share name. .localrequires Avahi (avahi-daemon) on the server and client.- If hostname does not resolve, use the server IP instead.
- Replace
-
Connect via terminal (temporary)
Install required packages for terminal access:
Terminal window sudo apt install smbclient cifs-utils -yTerminal window smbclient //{{SERVER_IP_VAR}}/shared -U {{USERNAME_VAR}}