chage command is used to change the expiration date of an account or password on a Linux system. This command is useful for system administrators who want to enforce password policies and ensure that user accounts are secure.
chage command is used to modify the password expiration time for a user account. The command can be used to set the maximum number of days between password changes, the minimum number of days between password changes, and the number of days of warning before a password expires.
The basic syntax of the
chage command is as follows:
chage [options] [username]
username is the name of the user whose password expiration date you want to change. If you do not specify a username, the
chage command will modify the password expiration settings for the current user.
chage command can be used with various options to modify the password expiration settings. Some of the most commonly used options are:
-m, --mindays DAYS: Specifies the minimum number of days between password changes.
-M, --maxdays DAYS: Specifies the maximum number of days between password changes.
-W, --warndays DAYS: Specifies the number of days of warning before a password expires.
-E, --expiredate YYYY-MM-DD: Specifies the date on which the user’s account will expire.
The following table lists the available options for the
||Set the number of days since January 1st, 1970 when the password was last changed.|
||Set the date on which the user’s account will expire.|
||Display help information.|
||Set the number of days of inactivity after a password has expired before the account is locked.|
||Display the current password aging information for the specified user.|
||Set the minimum number of days between password changes.|
||Set the maximum number of days between password changes.|
||Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.|
||Unlock the specified user’s password.|
||Set the number of days of warning before a password expires.|
If you encounter issues with the
chage command, here are some troubleshooting tips:
- If you receive an error message that says “You must provide a username or UID”, make sure that you have specified a valid username.
- If you receive an error message that says “Cannot lock /etc/passwd; try again later”, it means that another process is already modifying the
/etc/passwdfile. Wait for the other process to finish before running the
- If you receive an error message that says “Cannot determine the user name”, make sure that you have specified a valid username.
chagecommand is only available to users with root or sudo privileges.
- The password expiration settings set by the
chagecommand only apply to local user accounts. They do not affect accounts that are authenticated through a network service such as LDAP or NIS.
chagecommand modifies the
/etc/shadowfile, which contains encrypted password information. Do not modify this file manually unless you know what you are doing.