Linux chage Command: Manage Password Expiration and User Accounts
The chage command in Linux deals with user account expiration. The expirations are recorded in the /etc/shadow file.
Its options are:
-E date: Sets the expiration date in year, month, and day format
(YYYY-MM-DD). If "-1" (minus 1) is provided, it will remove the account expiration date.
- -l: Lists the user account settings. This option can be used by any user.
- -d N or YYYY-MM-DD: Sets the number N of days since the last password modification from 01/01/1970. It also accepts a date in YYYY-MM-DD format.
- -E N or YYYY-MM-DD: Sets number N of days when the account will be disabled since 01/01/1970. It also accepts a date in YYYY-MM-DD format.
- -I N: Sets the number N of days of inactivity after password expiration when the account will be disabled.
- -m N: Sets the minimum number N of days a password is valid. A zero value allows the user to change the password at any time.
- -M N: Sets the maximum number N of days a password is valid, forcing the user to change it.
- -W N: Sets the number N of days when a warning will be given to the user before the password change.
The default parameter definitions for user accounts are in the /etc/login.defs file
Example:
# chage –E 2016-05-23 cristiane
The chage command can also operate interactively, just informing the user account without any option:
# chage arthur Changing the aging information for arthurEnter the new value, or press ENTER for the default Minimum Password Age [0]: 10 Maximum Password Age [99999]: 60 Last Password Change (YYYY-MM-DD) [2019-10-17]: Password Expiration Warning [7]: 7 Password Inactive [-1]: 10 Account Expiration Date (YYYY-MM-DD) [2019-10-31]: 2019-10-31
Account expiration information can be viewed with the "-l" option of the command.
Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.
Liked it? Share
That was just one piece. The course teaches the whole path — from your first command to exam day.