Ubuntu

PASSWD Command in Linux

Changing passwords is a prevalent task regardless of the operating system you are working with. The command used in Linux for doing this is known as PASSWD. In this article, we will be discussing the usage of this command in Linux.

Purpose of the PASSWD Command in Linux

The PASSWD command is mainly used for changing a Linux system’s password and setting the expiration time for a particular password, deleting the password of a user account, making a user account inactive after its password expiration, etc. You will be able to learn more about this command by going through the following sections of this article.

Options That Can Be Used With the PASSWD Command

To know about all the options that you can use with the PASSWD command in Linux, you can run the following command:

$ passwd --help

The image shown below displays all the different options that can be used with the PASSWD command in Linux:

How To Change the Current User Account Password With the PASSWD Command

If you intend to change the password of the currently logged-in Linux user account, then you will have to run the PASSWD command in the following manner:

$ passwd

Once you run this command, you will be asked to enter the current password of your system, as shown in the following image:

After providing the current user account password correctly, you will be prompted to enter a new password for this account, as shown in the following image:

Then, you will be asked to re-enter the new password as follows:

Finally, you will be presented with a success message stating that your password has been updated successfully.

How To Change the User Account Password of Another User With the PASSWD Command

If you want to change the password of a user account other than the currently logged-in Linux user, then the process of doing so is slightly different from the one shared previously. First, you need to run the PASSWD command with sudo privileges followed by the username of the target user account, as shown in the following image:

$ sudo passwd system2

Here, “system2” is the account username whose password we wish to change with the PASSWD command.

Upon executing this command, you will be asked to enter the sudo password, i.e., the password of the currently logged-in user account, as shown in the following image:

When you provide this password correctly, you will be asked to enter a new password for the target user account, as shown in the following image:

Then, you will be asked to re-enter the new password for confirmation, as shown below:

Finally, your password for the target user account will be updated with a success message, as shown in the following image:

Conclusion

This article aimed to give you a brief overview of the working of the PASSWD command in Linux. After explaining the purpose of this command, we shared with you the method of accessing all the options you can use with this command. Then, we shared with you two different use-cases of this command, with the help of which you can easily change the password of a Linux user account.

Similar Posts