A password is a word, phrase, or string of characters used to verify the identity of a user during the authentication process. It is used to differentiate an authorized user from an unauthorized user.
Today we will explore how to change a password on Ubuntu 22.04 using two different ways. The first method involves changing the password using the command line (Terminal). In the second method, we will see how a password is changed using Graphical User Interface (GUI).
Following are the two ways you can change a password on Ubuntu 22.04:
Method 1: Change Password via Command Line
Change the Current User’s Password via Command Line
Let’s begin by changing your own password. To do that, all you need is a passwd command, followed by your username as shown below:
Once the command is executed, you will be asked to enter your current user password. Once it is accepted, you can now type the new password you wish to set and hit enter to save it.
Change Another User’s Password
In the previous demo, we saw how to change a current user’s password. To change another user’s password use the two simple methods: switch to the root account or use the standard account but with sudo.
Considering the first scenario that you have root access, then switch to it using the following command:
You will be asked for the root password to be able to use root account.
Once you have got the access, you can now change the password. Use the passwd command followed by the username to accomplish that.
Given the second scenario, you hold sudo privileges. To change the password, run the previous command but with sudo this time.
You will be asked to enter your current user password. Once accepted, you can type the password you are changing for a particular account.
Change Root User’s Password via Command Line
Now, it is time to see how we can change the password for a Root user. Again, you either need to switch to the root account or use the standard account with sudo.
Suppose you have root level access, then switch to the root account by issuing the following command:
Now, you can change the password for root using the passwd command as demonstrated below:
You will be asked to enter the new password twice. Once the password is changed, you will see a confirmation message like this on your terminal:
To change the password directly using sudo, you will have to execute the passwd command with sudo followed by root username as shown below:
Again, you will be asked to provide the new password twice.
Method 2: Change User Password via GUI
Now that we have explored how to change a password using the command line, let’s now explore how it could be done using Ubuntu’s Graphical User Interface (GUI).
To do that, go to the Settings.
Then find the Users tab in the left panel.
To change the password first, enter the current password to authenticate yourself. Then provide the new password you want to keep. Make sure it matches a good security strength.
In today’s guide, we saw in detail how to change a paAssword in Ubuntu. We first explored how to change a password via Ubuntu’s command line and then we saw how the same thing can be achieved via Ubuntu’s GUI.