Skip to content

SMB

Setup guide for sharing files over a local network using Samba (SMB/CIFS) between Linux and other devices.



Server

  1. Install

    Install the SMB server package to enable file sharing.

    Terminal window
    sudo apt update && sudo apt install samba -y
  2. 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}}
  3. smb.conf

    Terminal window
    sudo nano /etc/samba/smb.conf
    /etc/samba/smb.conf
    [shared]
    path = {{SMB_SHARE_VAR}}
    read only = no
    browsable = yes
    guest ok = no
  4. Restart service

    Terminal window
    sudo systemctl restart smbd

    Optionally enable on boot:

    Terminal window
    sudo systemctl enable smbd
  5. Allow through firewall (optional)

    Allow access for SMB traffic.

    Terminal window
    sudo ufw allow samba

Client

  1. Access share

    smb://{{SERVER_IP_VAR}}/shared

    Or using hostname (if mDNS/Avahi is working):

    smb://{{HOSTNAME_VAR}}.local/shared

    Notes:

    • Replace shared with your share name.
    • .local requires Avahi (avahi-daemon) on the server and client.
    • If hostname does not resolve, use the server IP instead.

  2. Connect via terminal (temporary)

    Install required packages for terminal access:

    Terminal window
    sudo apt install smbclient cifs-utils -y
    Terminal window
    smbclient //{{SERVER_IP_VAR}}/shared -U {{USERNAME_VAR}}