Skip to content

Instantly share code, notes, and snippets.

@GrumpyChunks
Last active July 27, 2020 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GrumpyChunks/7de890540a235e8fe7c1334001cc5ef0 to your computer and use it in GitHub Desktop.
Save GrumpyChunks/7de890540a235e8fe7c1334001cc5ef0 to your computer and use it in GitHub Desktop.
How to configure samba on Linux

If not already installed, you need to install samba server. The example below is for Debian (and derivatives)

sudo apt install samba

Ensure samba isn't running before continuing.

sudo systemctl stop samba

Make a backup of the configuration file

sudo mv /etc/samba/smb.conf /etc/samba/smb.conf_backup

Now recreate the config file without all the comments

sudo bash -c 'grep -v -E "^#|^;" /etc/samba/smb.conf_backup | grep . > /etc/samba/smb.conf'

Set passwords for the users (replace 'grumpychunks' in the example below with each username in turn)

sudo smbpasswd -a grumpychunks

Now by editing /etc/samba/smb.conf, add the required shares, for example

[homes]
   comment = Home Directories
   browseable = yes
   read only = no
   create mask = 0700
   directory mask = 0700
   valid users = %S
   guest ok = no
[storage]
   comment = Storage Volume
   path = /mnt/storage
   browseable = yes
   read only = no
   create mask = 0660
   directory mask = 0771
   valid users = grumpychunks
   writeable = yes
   guest ok = no

Before testing from a remote system, don't forget to start samba again

sudo systemctl start samba

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment