How To Set or Change Linux User Password

How To Set or Change Linux User Password

To set or change a Linux user's password, you can use the passwd command.

To change your own password, simply run the passwd command without any arguments:

passwd
Sourc‮w:e‬ww.lautturi.com

You will be prompted to enter your current password, and then to enter your new password twice.

To change the password for another user, you will need to use the sudo command to run passwd as the root user. For example, to change the password for the user user2, you can use the following command:

sudo passwd user2

You will be prompted to enter a new password for the user.

Alternatively, you can use the chpasswd command to change a user's password in a script or batch process. This command takes a list of colon-separated username and password pairs as input, and updates the passwords for the corresponding users.

For example, to change the password for the user user2 to mynewpassword, you can use the following command:

echo "user2:mynewpassword" | sudo chpasswd

Keep in mind that Linux passwords are encrypted for security, so you will not be able to see the actual password when you set it.

Created Time:2017-10-29 22:08:31  Author:lautturi