Change the Raspbian root password

A fresh install of Raspbian on a Raspberry Pi allows you to log in using the username pi and password raspberry. Using sudo will enable you to issue root commands, with which you can do or install anything. You don’t need to enter a password to use sudo as the root password is disabled by default.

If you are annoyed at having to sudo every time and would like to be the root user, you must first set a password for the root account. Edit this file using the supplied Linux text editor nano, for which you will need to use sudo as no root password is set yet:

sudo nano vipw

Change the line

root:x:0:0:root:/root:/bin/bash

remove the x so the line reads

root::0:0:root:/root:/bin/bash

Reboot the Raspberry Pi

sudo reboot

Use root as the username and press Enter (Return) and you will have root access without a password (that’s why we removed the x above). After you change the root password you will be able to log in directly as root.

Change the root password

sudo passwd root

[Enter your chosen root password twice]
Make sure you remember what it is!

Now you will be able to log in to your Rasperry Pi as root with the password you have chosen, without ever having to sudo again!

Alternatively, the command sudo su will log you in as root without the use of a password.

Be careful! The root user has complete access to every file, so you can really damage the Raspbian system if you don’t know exactly what you are doing. If you really destroy it, you will have to reinstall Raspbian on the SD card.