Sudo and The Root User on Ubuntu

Sudo and The Root User on Ubuntu

To do many of the administrative tasks on Ubuntu, for example changing the password of a user, setting date and time, editing configuration files, setting up startup processes, partitioning drives, installing new software, removing software etc we need super user or root privilege.

But it’s not a good thing to always have root privilege in your hand. Imagine you are working with an important file, and mistakenly you deleted it. Your computer might not start next time you reboot. As a normal user, you can’t delete system files. So it’s good to have root permission, but only when you really need it.

This is where sudo comes in. sudo grants you root privilege temporarily. So you can do everything as root can and still run as a normal user. This act protects a Linux user from making intentional mistakes and ending up destroying his/her operating system.

In this tutorial we are going to learn how to use sudo to execute commands that root users can do.

This is a step-by-step tutorial on how to use sudo to run commands that only superuser can do on Ubuntu. To follow this tutorial, you need to have the following requirements:

• A computer with Ubuntu operating system installed.
• Basic knowledge of Ubuntu terminal. With basic I mean, how to open a terminal on Ubuntu and how to execute commands.

Step 1: First open the terminal of your Ubuntu operating system. You can open your terminal by pressing Control, Alt and T at the same time. You can also go to the Unity dashboard and search by the keyword “Terminal” and click on the terminal. Or you can right click on the Desktop and click on “Open Terminal”.

Step 2: Now let’s say, you want to change the password of the root user. The command to change the password of any user is,
passwd username

To change root password, try the following command,
passwd root

You will see the following message,


“You may not view or modify password information for root.”

Sounds self-explanatory. So we need to be root to change the password of root.

Step 3: To change the root password, you can be root by using sudo command.

Now try the following command,

sudo passwd root

You will be prompted for your user password. Remember, it’s your standard user password. Type in the password and press enter.


Now you’re prompted for the root password. Type a password of your choice and press Enter.


Retype your password and press Enter.


“Password updated successfully”. Great!


That’s how you use sudo to become root as a s