To change a password in Unix, you can use the passwd
command. This command allows you to change the password for your own user account or for another user account on the system.
To change your own password, simply run the passwd
command without any options or arguments:
passwd
The passwd
command will prompt you to enter your current password, and then it will prompt you to enter a new password and confirm it.
To change the password for another user account, you will need to use the passwd
command with the -u
option and specify the username of the user account. For example:
sudo passwd -u username
Replace username
with the username of the user account whose password you want to change. The passwd
command will prompt you to enter the new password and confirm it.
Note that you will need to use sudo
to run the passwd
command if you are not the root user or if you do not have the necessary privileges to change the password for the specified user account.
You can also use the chpasswd
command to change the password for multiple user accounts at the same time. To use the chpasswd
command, you will need to create a file containing the username and password pairs, with one pair per line, separated by a colon. For example:
user1:password1 user2:password2 user3:password3
You can then use the chpasswd
command to read the password pairs from the file and update the passwords for the corresponding user accounts. For example:
sudo chpasswd < password_file
Replace password_file
with the name of the file containing the username and password pairs. This will change the passwords for the specified user accounts.
Note that the chpasswd
command is not available on all Unix systems. If it is not available on your system, you can use the passwd
command to change the passwords for individual user accounts.