PASSWD Command in Linux - Explained with Examples

PASSWD is the command used in Linux for Changing users passwords.

Here at LinuxAPT, we shall look into the usage of PASSWD command in Linux.


More about the PASSWD Command ?

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. 


PASSWD Command Options

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

$ passwd --help

This command will display 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 with the below command:

$ passwd
  • Once you run this command, you will be asked to enter the current password of your system.
  • After providing the current user account password correctly, you will be prompted to enter a new password for this account.
  • Then, you will be asked to re-enter the new password.
  • 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 above. 

To begin, you need to run the PASSWD command with sudo privileges followed by the username of the target user account:

$ 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
  • When you provide this password correctly, you will be asked to enter a new password for the target user account.
  • Then, you will be asked to re-enter the new password for confirmation.
  • Finally, your password for the target user account will be updated with a success message.


[Need help in fixing Linux issues ? We can help you. ]

This article covers an overview of how to use the PASSWD command in Linux. In fact, The passwd command modifies passwords for user accounts and manages the password validity period.


What is the general command for passwd ?

passwd general command is:

$ passwd  

The terminal prints out what user you are changing the password for. Type your current password, and then define and confirm your new password.

Related Posts