Raspberry Pi

How to Login as Root on Raspberry Pi OS

The Raspberry Pi OS when installed on the computer, a Pi user is created by default, but with this user has no privileges of administrative tasks. To execute the administrative tasks like to shut down the computer or to configure the boot files, you will need access to the root user.

In this write-up, different ways are explored by which we can access the root user account and make changes in the administrative files.

What is a root user in Raspberry Pi OS

The root user in the Raspberry PI OS is also known as the super user because it has almost every privilege to perform tasks on the Raspberry Pi OS, especially the administrative tasks. Tasks like to shutdown the Raspberry Pi, to reboot, and to update as well as upgrade the Raspberry Pi OS are all performed by the root users.

How to login as root user on the Raspberry Pi OS

As we discussed earlier, the users other than the root user, cannot perform the administrative tasks on the Raspberry Pi. To perform such tasks we have to login as the root user which can be done by executing any one of the mentioned below two commands:

To become root user from a normal user account use the command mentioned below:

$ sudo -i

Alternatively use:

$ sudo -s

The difference among two above commands is that if the account is protected by the password, you are advised to use the “-i” else if it is free of password then use the “-s”. Once you enter the root user, you can manage all the configuration settings and when done, we can exit the root user by typing a keyword “exit”.

What is a sudo command in Raspberry Pi

The users of the Raspberry Pi have no privileges of the root user, but instead of that they can run the administrative commands by using a keyword of “sudo” with the commands. For example, we will create a user “hammad” by using the command:

$ sudo adduser hammad

It will ask you to set the password for the new user “hammad” and also ask for some other required information about your name which you can skip as well:

The new user would not have full access to the machine as it is not in the sudo group. Now to add the user in the “sudo” group, we will use the following command:

$ sudo adduser hammad sudo

After adding this, we can run the “sudo” command to perform the administrative tasks.

How to know and remove the users from the sudo group in Raspberry Pi

In the above section, we have created a new user and added it in the sudo group so that the new user can enjoy all the privileges of a super user. But sometimes we want to remove the users from the sudo group, and for it we have to know whether they are present in the sudo group or not. To know the members of the sudo user, we will use the command:

$ grep 'sudo' /etc/group

Only hammad has been added in the “sudo‘ group, to remove the user hammad from the sudo group, we will use the command:

$ sudo gpasswd -d hammad sudo


The administrative tasks are those by which anyone can change the settings of the Raspberry Pi OS so it is not a good practice to assign all the rights of administrative tasks to everybody. For this reason, these administrative rights are enjoyed by the super user also known as root user or the users which are in the sudo group. In this write-up, we have learned the methods to login as a root user as well as to add in sudo groups to perform administrative tasks.

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.