How To Set/Change Root Password In Ubuntu?

How To Set/Change Root Password In Ubuntu?

   

This post was last updated on August 1st, 2020 at 03:37 pm

A root user is a most privileged user account in a Unix based operating system. It has access to all the commands and files of the system. A root user is also called a superuser or administrator because it is needed to perform administrative tasks.

It is used to perform tasks such as installing software, changing the ownership and permissions of files, and managing other user accounts which cannot be done with a normal user account.

Ahead in this article, we will see how we can set/change and disable or remove the password of the root user.

Root account in Ubuntu/Linux Mint

In Ubuntu or a distribution based on Ubuntu, a standard root account is created while the installation of the operating system but no password is assigned to it. Ubuntu comes sudo only by default, which means you are given the ability to execute a task with superuser privileges by using the sudo command. After installing OS If you want you can set or remove the password of the root account by using the terminal.

How to Set/Change the password of root

Since the root account in Ubuntu is created with no password. Use the following steps to assign a password-

1. You can set it in one go by using the following command –

sudo passwd root

This will ask you to enter the new Unix password, enter it and then retype the same password in the next line. Once the password gets assigned it will display a message that password updated successfully.

Now you can check it by using the following command –

sudo -

It will ask you to enter the root password, enter it. Now you will be logged in as root.

2. Another way to set or change the password of root is –

sudo -i

This will prompt you to enter the user password and then switched to root. Now enter the following command to set/change the password.

passwd

Again it will ask you to enter the new Unix password, enter it and then retype the same password in the next line. Once the password gets assigned it will display a message password updated successfully.

Use the following command to logout from the root –

exit

How to disable the root User Account?

Now if you want to disable the root account login, then execute the following command in your terminal.

sudo passwd -dl root

Where,

-d or --delete – The option will delete the password of a user and make a named account passwordless

-l or --lock – This option will disable the password of an account by changing it to a value which matches no possible encrypted value. It adds ! at the beginning of the password.

Now you can verify it by executing the following command-

sudo -

When you enter your root password it will display a message saying authentication failure. It means the root account login has been disabled.

To know more about passwd command see its manual page by using-

man passwd
Previous UMix 20.04 Update
Next How To Find IP Address From Domain Name In Linux/Unix?

About author

You might also like

Linux Terminal 0 Comments

How To Change User’s Password Through Terminal In Linux/Unix?

This post was last updated on August 1st, 2020 at 12:14 pmLinux or Unix is the multi-user operating system that means more than one user can use system resources simultaneously.

How To 0 Comments

How To Install Docker On Ubuntu 20.04 LTS?

This post was last updated on August 1st, 2020 at 08:47 pmDocker is a platform that makes it easier to create, deploy, and use an application using containers. A container

Linux Topics 3 Comments

How to Create a USB Bootable Ubuntu Live Disk

Looking to make a Live Ubuntu USB disk? then you have arrived at the right place. Here I will provide you direct download link to the Ubuntu ISO image, Linux

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply