How to change the password of sudo, root or another user in Ubuntu?

password-key

If you are new to Ubuntu, you might want to know how to change password on your Ubuntu system using bash shell or command line.

After all, it is good security practice to change passwords for any user, especially Superuser, who can perform all confidential operations in Ubuntu.

Only a superuser or root can change the password of any user account. Other users can only change their own passwords.

User passwords are changed in Ubuntu using the passwd command. In this article, we will explain how a root user can change their own password in Ubuntu.

Process to change user password in Ubuntu and derivatives

In order to carry out this process we need to use the command line in Ubuntu, so you can open one by looking for the terminal in your application menu or with the shortcut "Ctrl + Alt + T".

Now we must log in as root user, since only a root user can change their own password, for this in the terminal we are going to type the following command:

sudo -i

The system will ask you to enter the current sudo password. This done, pTo change the password of the root user, in the terminal we are going to type the following command:

passwd

When they enter the passwd command, the system will ask you to enter the new password for your root user, then the system will ask you to retype the new password. After doing so, the system will confirm that the password is updated correctly.

Now whenever you need to log in as root or perform any installation and configuration operations that require root authority, you are using this new password.

Once this process is done, it is enough to close the root session, for this in the terminal we must type the following command:

exit

But what happens when you need to change another user's password if you are the system administrator.

How to change another user's password in Ubuntu and derivatives?

Well, if you need to change the password of another user, you can do this in a similar way to the previous processOnly here you must indicate the name of the user to whom you will assign a new password.

You can do this with the following command, In this case we will make the password change to root, although as mentioned you can make the change to any other user on the system:

sudo passwd root

When entering this command, it will ask them to enter the new password, once this has been done, it will ask for confirmation again and then proceed to make the changes,

As you can see, it is not necessary that you do it from root.

How to recover the root password?

Now you possibly entered this article, thinking that the title referred to the recovery of a forgotten password.

Well, We will not leave that aside and we will explain a simple method for it.

To recover your root password, you must restart your computer. When this happens, after the BIOS screen of your computer passes, you will have to type the ESC or SHIFT key several times depending on the case.

Since depending on the BIOS you have, you may execute some action with ESC, so you must use shif, although you can search the network for some methods to access the Ubuntu Recovery mode.

Esto You have to do it so that the grub options are enabled, and being here you must select the start option that contains "Recovery mode" at the end.

Once this option is selected, you type Enter and it will begin to load the system, all good up to here. After a minute or so you should be on a screen with several options, including one that says "root".

You must position yourself in it with the help of the keyboard navigation dates and press Enter. Here you will be inside a console.

In it you can apply the same previous procedure that we explained to you to change the password, but first you must mount the root partition with:

mount -rw -o remount /

And then proceed to make your password change with:

passwd nombredeusuario

Finally, as an additional comment, this process can be a double-edged sword, as someone unauthorized can create a new user with administrator permissions and access your system or change your credentials. In this case I wonder, how can we disable this option?


2 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   jairo said

    excellent it served me a lot and more in ubuntu 19.04

  2.   armakaizen said

    Thank you very much for the contribution. It helped me in installing ubuntu with docker.