Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Samba Cheatsheet

User Management

Add Users

Adding users for samba that dont have a home directory and can't login with SSH.

sudo useradd \
  --no-create-home  \
  --shell /usr/sbin/nologin  \

You should see the user like so in the /etc/passwd file:


Set User Password

Then set a password for the user for the first time:

sudo smbpasswd -a $USERNAME

Samba Service

Restart Samba Service

sudo service smbd start

You don't have to restart the service after creating a user and setting their password. It should immediately take effect.


Add Another Share

Add a section like below to the /etc/samba/smb.conf file. Obviously tweak the values as necessary.

  comment = Read only share except for authorized users
  path = /mydata/mystuff/
  public = no
  guest ok = no
  read only = yes
  create mask = 0644
  directory mask = 0755
  force group = mygroup
  write list = myname, @mygroup


Last updated: 3rd October 2019
First published: 24th June 2019