Off the Crust: Creating a New RPi User

tripleqmark
3 min readSep 2, 2017

--

Off the Crust articles will be shorter than my other RPi articles, focused on doing one particular task or set of tasks within the Raspberry Pi.

The instructions below are based off those provided by the Raspberry Pi Foundation, with some images attached. You can find the full text here.

Creating a New User

To create a new user on the RPi, while logged in as a sudo user (such as the initial pi user, enter the following, replacing username with the name of the new user:

sudo adduser username

It will then ask you for a password for the new user, and like logging in, it won’t show you your keystrokes. I would suggest using a strong password here, as this will be your main point of defense against attacks from the internet.

After confirming your password, it will ask you for some additional information. I just set the full name to be the same as my username and left the remaining fields blank, as shown below. You can fill out whatever field you feel are relevant. Finally, type y and press Enter to confirm that the information you have entered is correct.

Adding sudo User Permission

Once you have created your new user, you may wish to provide them with sudo user permission, which is a lot like Administrator access on Windows and allows you to install or modify anything onto the RPi. You can do this by typing the following into the console:

sudo visudo

This will open up the nano text editor and the screen should look like the following:

Scroll down and locate the lines that says:

#User Privilege Specification
root ALL=(ALL:ALL) ALL

Underneath the root user, add a line that says, so it looks like the image below, although with your new user instead.

username    ALL = NOPASSWD: ALL

Once that’s done, press Ctrl+X to exit and when prompted type y and press Enter to save the document. Your new user now has sudo user permissions.

Accessing Your New Account

To access the new user account, you can either logout or reboot your RPi.

If you type logout into the console and press Enter, the PuTTY screen will close and you will need to open a new session, which will present the login screen.

If you type sudo reboot into the console and press Enter, the PUTTY screen will remain and you will receive an error that the server has severed the connection. Wait 30 seconds while the Raspberry Pi reboots and then right click on the title bar, at the top of the PuTTY screen and select Restart Session to be returned to the login screen.

Updating a Password

You can update the current user’s password by typing the following into the console:

passwd

The RPi will then prompt you to enter your current password, followed by your new password.

You can update a password for any user, while you are a sudo user by entering the following into the console, substituting their username.

sudo passwd username

Finally, a password for any user can be deleted by entering the following into the console:

sudo passwd username -d

Deleting a User

You can delete a user, while logged in as a sudo user yourself, by entering the following into the console:

sudo userdel username

If you include the -r flag, it will also delete that user’s home directory:

sudo userdel -r username

I hope you found this helpful. For more of my articles on the Raspberry Pi, check out my Build Log here.

--

--

tripleqmark
0 Followers

Dabbler: analog game design, programming, IoT, volunteering and other things.