The passwd command

Yaser Rahmati | یاسر رحمتی

In Linux, passwd command changes the password of user accounts. A normal user may only change the password for their own account, but a superuser may change the password for any account. passwd also changes the account or associated password validity period.

Example

  • The passwd utility is used to update user's authentication token(s).

[apa@academy mydir]$ passwd
Changing password for user apa.
Changing password for apa.
(current) UNIX password:
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[apa@academy mydir]$
  • Display account status information.

[root@academy mydir]# passwd -S apa
apa PS 2023-12-23 0 99999 7 -1 (Password set, SHA512 crypt.)
[root@academy mydir]#
  • Lock the password of the named account.

[root@academy mydir]# passwd -l apa
Locking password for user apa.
passwd: Success
[root@academy mydir]# passwd --status apa
apa LK 1970-01-01 0 99999 7 -1 (Password locked.)
[root@academy mydir]#
  • Delete a user's password.

[root@academy mydir]# passwd -d apa
Removing password for user apa.
passwd: Success
[root@academy mydir]# passwd -S apa
apa NP 2023-12-23 0 99999 7 -1 (Empty password.)
[root@academy mydir]#
  • Immediately expire an account's password.

[root@academy mydir]# passwd -e apa
Expiring password for user apa.
passwd: Success
[root@academy mydir]#
  • Indicate password change should be performed only for expired authentication tokens (passwords).

[root@academy mydir]# passwd -e apa
Expiring password for user apa.
passwd: Success
[root@academy mydir]# passwd -k apa
Changing password for user apa.
Changing password for apa.
(current) UNIX password:
New password:
Retype new password:
passwd: expired authentication tokens updated successfully.
[root@academy mydir]#
  • This option is used to disable an account after the password has been expired for a number of days.

[root@academy mydir]# passwd -i 5 apa
Adjusting aging data for user apa.
passwd: Success
[root@academy mydir]# passwd -S apa
apa PS 1970-01-01 0 99999 7 5 (Password set, SHA512 crypt.)
[root@academy mydir]#

The syntax of the passwd command is :

 passwd [options] [LOGIN]

Last updated