Ubuntu

How to change the password on Ubuntu 20.04

If you are a regular Linux or system administrator, there will be likely times when you are required to change the password for your own user account or for another. Changing the password for a user account can be required for many reasons. You may want to change the password for your account if you suspect it to be compromised. It may also be required if you have forgotten your password. In any scenario, knowing how to change the user password in an OS is something you should be able to do.

In this article, you will learn how to change the user password on Ubuntu 20.04 LTS. This article will cover changing the password for the user accounts via Command line and the GUI.

Note: To change the password for any user other than your own user account, you will need a root account or the standard account with sudo privileges.

Changing current user password via Command line


To change your own password, you will simply need to type passwd followed by the user name:

$ passwd <username>

After running the above command, you will be required to enter the current password. Once you have provided the current password, you will be asked to set the new password for your account.

Changing password for another user

For changing the password for an account other than your own, either switch to the root account or use the standard account with sudo privileges.

1. If you have root account access, then switch to it:

$ su

Enter the root password and you will be login as a root user.

Now you can change the password for another user account by typing passwd command followed by user name:

$ passwd <username>

2. If you have sudo privileges, you can change the password by typing sudo followed by passwd command and the user name.

$ sudo passwd <username>

Enter the password for sudo, after that you will be able to change the password for any other user account. Enter the password and then enter it again to confirm.

The above output shows the new password has been updated successfully.

If you are not a root user and try to change the password for another user, you will see the following message:

Changing root user password via Command line

To change the password for a root user, either switch to the root account or use the standard account with sudo privileges.

1. If you have root account access, then switch to it:

$ su -

Enter the password for the root account and you will be login as a root user.

Now you can change the password for the root user account as follows:

$ passwd <username>

2. If you have sudo privileges, you can change the password by typing sudo followed by passwd command and the root.

$ sudo passwd root

Enter the password for sudo, after that you will be asked to set a new password for the root account. Enter the new password and then enter it again to confirm it.

The above output shows the new password has been updated successfully.

Changing user password via UI

1. Open the Settings utility using the right-click menu from desktop.

2. Then navigate to the Users tab from the left panel. Click the Unlock button at the top right corner.

We do not need to unlock if we are changing the current user’s password. However, to change the password for any other account, we will need to unlock it.

In the following dialog, type the password and click the Authenticate button.

Select the user account you want to change the password for. Under the Authentication & Login section, click the Password field.

The following Change Password dialog will pop-up. If you are changing the password for the current user, you will need to provide the current password. Then in the next fields, enter and re-enter the new password to confirm it. Once done, hit the Change button.

Now the new password has been set successfully.

That is all there is to it! Whether you use the command line or go with the UI procedure for changing the user account password, it involves only a few simple steps. You can follow either of the procedure for changing the user account password based on your preferences and ease of installation.

About the author

Karim Buzdar

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.