If you’re using a Raspberry Pi, chances are you’ll want to have more than one user. Maybe you want to set up a separate account for your kids, or maybe you need to share the device with others in your family.
Whatever the reason, it’s relatively easy to set up and manage multiple users on a Raspberry Pi.
In this article, we’ll go through everything you need to know about how to manage users in Raspberry Pi, so be sure to read it till the end!
Raspberry Pi User Management: How To Add A New User
Adding a new user to your Raspberry Pi is a simple process. Just open up a terminal window via the desktop and type the following command:
- sudo adduser <username>
Replace <username> with the username you want to use and press the Enter key. Once you hit Enter, you’ll be prompted to enter and confirm a password for the new user.
After that, you’ll be asked to provide some additional information, like the user’s full name. You can just keep hitting Enter to skip these questions and just go with the default values.
Once the process is complete, the new user will be added to your system and you can start using it right away.
The new user will also have an account-specific folder created automatically in the Home Folder. To access this new subfolder, e Manager from the Applications Menu under Accessories or from the TaskBar, and search for it under the Home Folder.
How Do I Create A Sudo User?
If you’ve followed all the steps above correctly, you should be able to log in to the new user account.
However, it’s important to note that this new user most likely won’t have sudo privileges and user permissions set up by default.
If you want to replace your old default Pi user account entirely and give this new user account sudo privileges, you can do so by adding the new user to the sudo group.
It’s quite straightforward, all you have to do is open up a terminal and type the following command:
- sudo adduser <username> sudo
And that’s about it, your new account should now be able to use the sudo command.
How To Add Users To A Group?
Another thing you might need to do after creating a new user in your Raspberry Pi is to add it to a few groups.
Again, this process is fairly simple, all you have to do is use the terminal and type the following add user command:
- sudo adduser <username> <groupname>
Replace <username> with the username of the user you want to modify, and <groupname> with the name of the group you want to add them to. Remember, you can add a user to multiple groups by just running the command multiple times.
There are a few groups that you might want to consider adding your new user to. For example, as mentioned previously, the sudo group will give them the ability to run commands with sudo, while the gpio group will let them access the GPIO pins on your Raspberry Pi.
You can confirm which groups a specific user is a part of by using the command:
- $ groups <username>
After inputting the command, you should get a response like this:
- newuser: newuser sudo gpio adm dialout cdrom
How Do I Remove A User From Raspberry Pi?
If you ever feel the need to delete users from Raspberry Pi, you’ll be glad to know that deleting a user is just as easy as creating a new one. Just open up a terminal and type the following command:
- sudo deluser <username>
Just remember to replace <username> with the username of the user you want to delete. Once you hit Enter, the user will be removed from your system, however, the user’s Home Folder will remain intact.
If you want to clear up space and delete both the user and their home folder, add the –remove-home option to the command like this:
- sudo deluser –remove-home <username>
With this option, everything associated with the user will be deleted, including the user’s Home Folder so use it with caution.
How To List Users In Raspberry Pi?
If you’ve already created a bunch of users on your Pi and are now wondering how to list users in Raspberry Pi and figure out how many of them are active, then you’re in luck.
Listing all the users is a simple process. Just open up a terminal and type the following command:
- cat /etc/passwd
Because all the users on the same system are stored in the /etc/passwd file, this will print out a list of all the active users on your system, along with some additional information like their user ID, home directory, and shell.
If you just want to see a list of the user names, you can use the grep command to filter the output:
- cat /etc/passwd | grep -v ‘/bin/false’
This will print out a list of all the users on your system, without any additional information cluttering up the terminal.
How Do I Change A User’s Raspberry Pi Login Password?
If you need to change a user’s Raspberry Pi login password, you can do so using the passwd command. Just open up a terminal and type:
- passwd <username>
Replace <username> with the username of the user whose password you want to change.
You’ll be prompted to enter and confirm the new password. Once you’re done, the user’s password will be updated.
Alternatively, you can also change the password using the desktop interface. Just go to Menu > Preferences > Raspberry Pi Configuration> System. Then, click on the “Users” tab and select the user whose password you want to change.
How To Set Up Automatic Login?
Lastly, if you don’t want to enter a password every time so you can quickly boot up or log in to your Raspberry Pi , you can set up automatic login.
To do this, open up the Raspberry Pi Configuration tool by going to Menu > Preferences > Raspberry Pi Configuration. Then, go to the “System” tab and select the “Boot” option. From there, you can choose to either boot into Desktop or CLI.
If you want to automatically login to the desktop, select “Desktop / Auto login to desktop” and enter the username of the user you want to login as.
If you want to automatically login to the command line, select “CLI / Auto login to CLI” and enter the username of the user you want to login as.
Once you’ve made your selection, click “OK” and reboot your Pi for changes to take effect. You’ll now find that the system will always automatically log you in as the selected user after every reboot.
As you can see, managing users on Raspberry Pi can be a simple process, especially if you use the appropriate terminal commands.
With just a few commands, you can add, delete, and change passwords for any user on your system. You can also set up automatic login to make things even easier.
Just remember to be careful when giving users sudo access or access to GPIO pins, as they could potentially damage your system if not used correctly or responsibly!
Note: If you are more of a ‘visual learner, the great video below will take you on a simple step-by-step walkthrough on how to easily setup and manage users:
- The Best Raspberry Pi Christmas Gifts - December 2, 2023
- Introducing The Raspberry Pi 5 – Everything We Know So Far - October 6, 2023
- Connecting A Color Sensor To A Raspberry Pi Or Arduino - September 21, 2023