
Linux Command Line
What is the “passwd” command?
The “passwd” command is a Linux utility used to change a user’s password. It is commonly used to set or change a password for a user account on a Linux system.
How to use the “passwd” command
The basic syntax for the “passwd” command is as follows:
passwd [options] [username]
- To change the password for the current user, simply type
passwd
and press Enter. - To change the password for a different user, use the
-u
option followed by the username, like so:passwd -u [username]
.
Examples of using the “passwd” command
Changing your own password
passwd
You will then be prompted to enter your current password, followed by your new password twice to confirm.
Changing another user’s password
sudo passwd -u [username]
You will then be prompted to enter the new password for the specified user.
Changing your own password with a password aging
chage -M [days] [username]
You will then be prompted to enter the new password for the specified user and set the maximum number of days the password is valid.
The “passwd” command is a simple yet powerful tool for managing user passwords on a Linux system. With the ability to change both your own password and the password of other users, it is a useful command for system administrators and regular users alike.