In this write-up, we will learn the method by which we can switch from one user to the other user in the Raspberry Pi and also learn the method of creating the user as well as removing the user.
How to add users in Raspberry Pi
To add the users in the Raspberry Pi, we use the “adduser” command with the username using the mentioned command, it will ask to set a password for the new user, enter the password:
After setting the password, it will ask you to enter the credentials of the user, enter the information you want to provide and in case you want to skip the step, simply press the “ENTER” key:
To verification of the newly created user of the Raspberry Pi, run the command:
The new user, hammad, has been created successfully.
How to switch the user in Raspberry Pi
The root user or we can say the default user of the Raspberry Pi is “Pi” (in most cases), to switch it from any other user, we will use the “su” command, like we will switch from Pi user to hammad user as:
It will ask for the password of the user hammad, on entering the correct password it will switch to the hammad user.
How to delete the user in Raspberry Pi
We can delete the users in the Raspberry Pi simply just like the way of adding them in Raspberry Pi. To demonstrate the deletion of the user from Raspberry Pi, we will delete the user “hammad” which was created in the above section using the command:
It will ask for the password but in this case, it generated the error of userdel, which means we can not delete the user, if the user is being used. To delete the user hammad, we will switch back to the root user which is “Pi” using the command:
Now again we will try to delete the user “hammad” from the Raspberry Pi using the command:
The user hammad has been successfully removed.
Conclusion
In Raspberry, we can manage the different users like to create, switch, and remove them using the command-line interface. Multiple users can use Raspberry Pi OS; each user can access and operate the device without shutting down the system simply by using switch user command. In this write-up, we have explained the procedure of switching from one user account to the other user account as well as adding and removing the users in the Raspberry Pi operating system.