passwd
passwd
Ā is an easy-to-use command line utility. It just resets the password for the user you specify. If you do not specify a user, it will change the passwd of an existing user.
[myuser@localhost ~]$ passwd Changing password for myuser. Current password: New password: Retype new password: The password has been changed. [myuser@localhost ~]$
The password is hashed and stored in the /etc/shadow file. So we can see our password hash here.
myuser@localhost ~]$ sudo cat /etc/shadow | grep myuser [sudo] password for myuser: bradr:$y$j9T$ZTaX5BW.GW1lgvP42cEh81$.r.Xamb/Vc52113Vw97c9i96.Qc7dAYDB3cYdtouXd6:19306:0:99999:7:::
The second field on this line is $y$j9T$ZTaX5BW.GW1lgvP42cEh81$.r.Xamb/Vc52113Vw97c9i96.Qc7dAYDB3cYdtouXd6
which is the hashed password. The difference between a hash and an encryption, is that an encryption goes through some complex algorithm to create some data, then you can put it back through the same algorithm to read the password back. It is two-directional. A Hash, on the other hand, is one-directional. It goes through a complex algorithm to produce some string of characters, but you should never be able to run that string of characters through any kind of algorithm to figure out what the password was. So this way, your password is not stored in any way on the Operating System, it just stores a hash. So when you put in your password, the system will run your password through the hashing algorithm, and compare the output to the hash that is in the /etc/shadow
Ā file. If the hashes are the same then you logically have the same password.