RPi NAS: Extras – Adding and Removing Users

19 January 2024

This is a brief post about adding and removing users to and from our NAS after the initial setup. There are lots of websites showing how to add a user to Samba. I just want to point out something that’s worth knowing when testing the setup of the new user.

This post is part of a series about building a Network-Attached Storage (NAS) with redundancy using a Raspberry Pi (RPi). See here for a list of all posts in this series.

Adding a User

You can add a user with

sudo adduser --no-create-home --disabled-password --disabled-login username

You’ll be asked to enter some additional information (but you don’t have to). Then the new user will be created and added to group users. No home directory and password will be created and the user won’t be able to log in on the RPi (none of that is necessary for a user that should only be able to connect via Samba). Next we add the user to Samba and setup their password with

sudo smbpasswd -a username

Finally reboot your system for the changes to take effect (or log out and log back in).

Now that we’ve added the user it seems normal (at least to me) to try to mount a Samba share on our main computer, using the newly created user. The following command (which we’ve been using to mount shares) fails:

That’s because we set the uid option to test_user, which doesn’t exist on our main system. So to test mounting the share we either add test_user to our main system or we run the command

sudo mount -t cifs // /Mount/Point -o user=test_user

which doesn’t contain the uid option. Leaving out uid means that we won’t be able to write to the Share but that shouldn’t be an issue if we only want to test if mounting works.

Removing a User

To remove a user we first remove it from Samba with

sudo smbpasswd -x username

Then we delete it from the system with

sudo userdel username


This post is tagged as:


Leave a Reply

Your email address will not be published. Required fields are marked *