SMB
Setup guide for sharing files over a local network using Samba (SMB/CIFS) between Linux and other devices.
Server
Section titled “Server”-
Install
Section titled “Install”Install the SMB server package to enable file sharing.
Terminal window sudo apt update && sudo apt install samba -y -
Set SMB password
Section titled “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
Section titled “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
Section titled “Restart service”Terminal window sudo systemctl restart smbdOptionally enable on boot:
Terminal window sudo systemctl enable smbd -
Allow through firewall (optional)
Section titled “Allow through firewall (optional)”Allow Samba UDP ports (NetBIOS).
Terminal window sudo ufw allow from {{SUBNET_VAR}} to any port 137,138 proto udpAllow Samba TCP ports (SMB).
Terminal window sudo ufw allow from {{SUBNET_VAR}} to any port 139,445 proto tcp
Client
Section titled “Client”-
Access share
Section titled “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)
Section titled “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}}