passwd is a basic Unix command that changes user’s password and lets you manage other aspects of password and account: lock account, delete password and report password status.
If you just type passwd, the command will assume that you want to change your own password. Just to be on the safe side, it will prompt you for your current password. If you don’t provide the correct password, the command will fail without allowing new password to be configured. This means if you accidentally forget to lock your workstation and leave a terminal session open, nobody will be able to change your password (becasue they don’t know your current password):
If you know root password or have sudo privilege, it’s possible to change Unix password for any user in the system.
To demonstrate it better: regular (non-root) user is not allowed to specify username for the passwd command (even their own one):
But with sudo privilege, it works just fine:
Among other things, it shows the date of last password change for the techstack user: 2018-01-19.
and this is what happens after I changed password (using commands above):
Note how the date changed to 2019-04-23.