passwd - Unix, Linux Command



NAME

passwd - change user password

SYNOPSIS

passwd [options] [LOGIN]

DESCRIPTION

The passwd command changes passwords for user accounts. A normal user may only change the password for his/her own account, while the superuser may change the password for any account. passwd also changes the account or associated password validity period.

OPTIONS

TAG DESCRIPTION
-a, --all This option can be used only with -S and causes show status for all users.
-d, --delete Delete a user's password (make it empty). This is a quick way to disable a password for an account. It will set the named account passwordless.
-e, --expire Immediately expire an account's password. This in effect can force a user to change his/her password at the user's next login.
-h, --help Display help message and exit.
-g, --noheadings Do not print a header line.
-h, --help Display help text and exit.
-i, --inactive INACTIVE This option is used to disable an account after the password has been expired for a number of days. After a user account has had an expired password for INACTIVE days, the user may no longer sign on to the account.
-k, --keep-tokens Indicate password change should be performed only for expired authentication tokens (passwords). The user wishes to keep their non-expired tokens as before.
-l, --lock Lock the password of the named account. This option disables a password by changing it to a value which matches no possible encrypted value (it adds a '!' at the beginning of the password).

Note that this does not disable the account. The user may still be able to login using another authentication token (e.g. an SSH key). To disable the account, administrators should use usermod --expiredate 1 (this set the account's expire date to Jan 2, 1970).

Users with a locked password are not allowed to change their password.
-n, --mindays MIN_DAYS Set the minimum number of days between password changes to MIN_DAYS. A value of zero for this field indicates that the user may change his/her password at any time.
-q, --quiet Quiet mode.
-r, --repository REPOSITORY change password in REPOSITORY repository
-R, --root CHROOT_DIR Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.
-S, --status Display account status information. The status information consists of 7 fields. The first field is the user's login name. The second field indicates if the user account has a locked password (L), has no password (NP), or has a usable password (P). The third field gives the date of the last password change. The next four fields are the minimum age, maximum age, warning period, and inactivity period for the password. These ages are expressed in days.
-u, --unlock Unlock the password of the named account. This option re-enables a password by changing the password back to its previous value (to the value before using the -l option).
-w, --warndays WARN_DAYS Set the number of days of warning before a password change is required. The WARN_DAYS option is the number of days prior to the password expiring that a user will be warned that his/her password is about to expire.
-x, --maxdays MAX_DAYS Set the maximum number of days a password remains valid. After MAX_DAYS, the password is required to be changed.

EXAMPLES

Example-1:

Change your own password:

$ passwd

output:

$ passwd
Changing password for ubuntu.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Example-2:

Change the password for the user named username:

$ sudo passwd username

output:

$ sudo passwd user1
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Example-3:

Check the status of the password for the user named user1:

$ sudo passwd -S user1

output:

user1 P 05/13/2014 2 365 7 28

Here, we see the user's name (user1), followed by a P, indicating that his password is currently valid and usable. 
The password will expire on May 5, 2014. user1 cannot change his password more often than every 2 days, and must change the
password every 365 days. He will be warned 7 days before a required password change, and if he allows his password to expire,
his account will be disabled 28 days later.

Example-4:

Checks the password status for all user accounts, system-wide:

$ sudo passwd -S -a

output:

root L 12/27/2016 0 99999 7 -1
daemon L 08/05/2015 0 99999 7 -1
bin L 08/05/2015 0 99999 7 -1
sys L 08/05/2015 0 99999 7 -1
sync L 08/05/2015 0 99999 7 -1
games L 08/05/2015 0 99999 7 -1
man L 08/05/2015 0 99999 7 -1
lp L 08/05/2015 0 99999 7 -1
mail L 08/05/2015 0 99999 7 -1
news L 08/05/2015 0 99999 7 -1
uucp L 08/05/2015 0 99999 7 -1
proxy L 08/05/2015 0 99999 7 -1
www-data L 08/05/2015 0 99999 7 -1
backup L 08/05/2015 0 99999 7 -1
list L 08/05/2015 0 99999 7 -1
irc L 08/05/2015 0 99999 7 -1
gnats L 08/05/2015 0 99999 7 -1
nobody L 08/05/2015 0 99999 7 -1
libuuid L 08/05/2015 0 99999 7 -1
syslog L 08/05/2015 0 99999 7 -1
messagebus L 12/27/2016 0 99999 7 -1
dnsmasq L 12/27/2016 0 99999 7 -1
landscape L 12/27/2016 0 99999 7 -1
sshd L 12/27/2016 0 99999 7 -1
libvirt-qemu L 12/27/2016 0 99999 7 -1
libvirt-dnsmasq L 12/27/2016 0 99999 7 -1
ubuntu P 01/06/2017 0 99999 7 -1
user1 P 01/06/2017 0 99999 7 -1

 

Example-5:

Lock the password for user user1. user1 will be unable to log in until a system administrator unlocks it:

$ sudo passwd -l user1

output:

passwd: password expiry information changed.

Example-6:

Unlock user1's password. It will automatically be reset to whatever it was before it was locked, and user1 will be able to log in again:

$ sudo passwd -u user1

output:

passwd: password expiry information changed.

Example-7:

Expire user1's password. The next time he logs in, he will be required to set a new password.

$ sudo passwd -e user1

output:

passwd: password expiry information changed.

next time user login:

$ su user1
Password:
You are required to change your password immediately (root enforced)
Changing password for user1.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:

Example-8:

Delete a user's password (make it empty). This is a quick way to disable a password for an account. It will set the named account passwordless.

$ sudo passwd -d user1

output:

passwd: password expiry information changed.

 

Print
Advertisements