Skip to content

Click on each book below to review & buy on Amazon.

As an Amazon Associate, I earn from qualifying purchases.


CompTIA Linux+ XK0-005 - 2.2 - Account Management: chage

Identity management plays a vital role in ensuring the security and efficient administration of user accounts in a Linux environment. The chage command is a powerful utility that allows you to modify user account aging and expiration settings. This guide will walk you through the process of using the chage command for account management, explain its various options, and their functionalities.

Understanding chage

The chage command is used to change the password aging and expiration settings for user accounts in Linux. It provides the following functionalities:

  • Password Aging: chage allows you to set password aging policies for user accounts. This includes options like password expiration, password aging period, and warning period before password expiration.

  • Account Expiration: chage also enables you to set an expiration date for user accounts. This allows system administrators to enforce regular account reviews and ensure that inactive or unnecessary accounts are disabled or removed.

  • Password Change Date: With chage, you can view or modify the last password change date for a user account. This information can be useful for auditing and security purposes.

Using chage for Account Management

The chage command provides a range of options to manage user account aging and expiration. Here are some common options and their functionalities:

  • -M, --maxdays <days>: Sets the maximum number of days a password is valid. After this period, the password will expire and the user will be required to change it.

  • -m, --mindays <days>: Specifies the minimum number of days that must pass before a password can be changed. This prevents users from changing their password too frequently.

  • -W, --warndays <days>: Sets the number of days before password expiration that the user will receive a warning. This allows users to prepare for an upcoming password change.

  • -E, --expiredate <date>: Sets an explicit expiration date for the account. After this date, the user account will be disabled and the user will no longer be able to log in.

  • -d, --lastday <date>: Sets the date when the user account will be disabled. This is similar to setting an expiration date but specifies the last day the account will be active.

  • -I, --inactive <days>: Specifies the number of days after the password expires that the account will be disabled. This helps enforce a period of inactivity before the account is completely disabled.

  • -R, --root <directory>: Changes the root directory for the chroot() call. This is typically used in conjunction with a chroot environment to modify accounts in a separate root directory.

chage Examples

  • Set maximum password age for a user:

    chage -M 90 username
    

    This command sets the maximum password age for the specified user (username) to 90 days. After 90 days, the user will be prompted to change their password.

  • Set minimum password age for a user:

    chage -m 7 username
    

    This command specifies that the user (username) must keep their password for at least 7 days before they can change it. This prevents frequent password changes.

  • Set password expiration warning for a user:

    chage -W 7 username
    

    With this command, the user (username) will receive a warning message 7 days before their password expires. This gives them time to prepare for a password change.

  • Set explicit account expiration date:

    chage -E 2024-12-31 username
    

    This command sets the account expiration date for the user (username) to December 31, 2024. After this date, the account will be disabled, and the user will no longer be able to log in.

  • View account aging information for a user:

    chage -l username
    

    This command displays the current account aging information for the specified user (username), including password expiration, password change date, and account expiration date.

These are just a few examples of how you can use the chage command.

Conclusion

The chage command provides a comprehensive set of options for managing user account aging and expiration in Linux. By understanding the various options available with chage and their functionalities, you can effectively enforce password policies, set expiration dates, and monitor account aging for improved security and account management. By following the steps outlined in this guide and utilizing the appropriate chage options, you can confidently implement identity management using the chage command and ensure the integrity and security of your Linux system.


Support DTV Linux

Click on each book below to review & buy on Amazon. As an Amazon Associate, I earn from qualifying purchases.

NordVPN ®: Elevate your online privacy and security. Grab our Special Offer to safeguard your data on public Wi-Fi and secure your devices. I may earn a commission on purchases made through this link.