Search notes:

Shell command: passwd

Change a user's password:
$ passwd mySecretPassword
Root can change another user's password:
# echo 'mySecretPassword
mySecretPassword
' | passwd rene
In order to change passwords in shell scripts or batch mode, chpasswd should be used.

Options

-a --all Shows status for all users, can only be used with -S
-d --delete Delete (empty) a user's password.
-e --expire Immediately expire an account's password - user needs to change the password at next login.
-h --help
-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 by prepending a ! to its encrypted value so that effectively no password fits the encrypted password - does not disable the account as 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. Users with a locked password are not allowed to change their password. See also -u
-n --mindays MIN_DAYS Set the minimum number of days between password changes to MIN_DAYS. A value of zero indicates that the user can always change the password.
-q --quiet
-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. (Only absolute paths are supported)
-P --prefix PREFIX_DIR Apply changes to configuration files under the root filesystem found under the directory PREFIX_DIR. This option does not chroot and is intended for preparing a cross-compilation target. Some limitations: NIS and LDAP users/groups are not verified. PAM authentication is using the host files. No SELINUX support.
-S --status Display account status information. 1) Loginname, 2) L = Locked, NP = no password , P has password, 3) date of last change, 4) minimum age, 5) maximum age, 6) warning period, 7) inactivity period (last four values expressed in days)
-u --unlock Unlock the password of the named account to value used before using -l.
-w --warndays WARN_DAYS Set the number of days of warning before a password change is required.
-x --maxdays MAX_DAYS Set the maximum number of days a password remains valid. After MAX_DAYS, the password is required to be changed. Passing the number -1 as MAX_DAYS will remove checking a password's validity.
-s --stdin This option is used to indicate that passwd should read the new password from stdin (which can be a pipe).

See also

useradd
Shell commands
/etc/passwd

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Linux/sh...', 1758200475, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Linux/shell/commands/passwd(76): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78