Raspberry Pi

How to add and switch users on Raspberry Pi operating system

The Raspberry Pi is a Debian-based Linux distribution in which we can manage the operating system in a similar way as in other Debian-based distributions. The Raspberry Pi OS is a multi-user operating system that means different users can operate a single system so that they can have the privacy of their data stored in the system as no other user can access it (until he has the authentication password of that user account).

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:

$ sudo adduser hammad

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:

$ ls /home

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:

$ su hammad

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:

$ sudo deluser hammad

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:

$ sudo su pi

Now again we will try to delete the user “hammad” from the Raspberry Pi using the command:

$ sudo deluser hammad

The user hammad has been successfully removed.


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.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.