Skip to content

Command chage on Linux (account expiration)

The chage command in Linux deals with the expiration of user accounts. Expires are recorded in the /etc/shadow file.

Your options are:

-And date: Enter the expiration date in the format year, month and day

(YYYY-MM-DD). If “-1” (minus 1) is entered, it will remove the account’s expiration date.

  • -l: Lists the user’s account settings. This option can be used by any user.
  • -d N or YYYY-MM-DD: Configures the number N of days since the last password modification since 01/01/1970. It also accepts a date in the format YYYY-MM-DD.
  • -E N or YYYY-MM-DD: Set the number of days on which the account will be disabled since 01/01/1970. It also accepts a date in the format YYYY-MM-DD.
  • -I N: Configures the number of days of inactivity after the expiration of the password in which the account will be disabled.
  • -m N: Configures the minimum number of days a password is valid for. A zero value allows the user to change passwords at any time.
  • -M N: Configures the maximum number of days a password is valid for, forcing the user to change it.
  • -W N: Configures the number N of days in which a warning will be given to the user before the password is changed.

The default parameter settings for user accounts are in the /etc/login.defs file

Example:

# chage —E 2016-05-23 Christians

The chage command can also operate interactively, just informing the user’s account without any options:

# chage arthur <br></br>Changing the aging information for Arthur <br></br>Enter the new value, or press ENTER for the default <br></br>Minimum Password Age [0]: 10 <br></br>Maximum Password Age [99999]: 60 <br></br>Last Password Change (YYYY-MM-DD) [2019-10-17]: <br></br>Password Expiration Warning [7] :& nbsp; 7

Inactive Password [-1]: 10
Account Expiration Date (YYYY-MM-DD) [2019-10-31]: 2019-10-31 Account expiration information can be viewed with the “-l” command option.

Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.

Did you like it?

Share