Linux Tutorial

Linux File/Directory Management

Linux Packaging And Compression

Vim Text Editor

Linux Text Processing

Linux Software Installation

Linux User/User Group Management

Linux Permission Management

Linux Filesystem Management

Linux Advanced Filesystem Management

Linux System Management

Linux Backup and Recovery

Linux System Service Management

Linux System Log Management

Linux Boot Management

LAMP/LNMP Environment

SELinux Management

Linux chage Command: Modify User Password Status

The chage command in Linux (short for "change age") is a utility used to manage password aging policies for user accounts. It enables administrators to set expiration dates for passwords, ensuring users change their passwords periodically for security reasons. In this tutorial, we will discuss how to use the chage command effectively, along with various options and examples.

  1. Basic usage of the chage command:

    To display the current password aging settings for a user, use the chage command with the -l or --list option followed by the username:

    sudo chage -l username
    

    This command will display information such as the date of the last password change, minimum and maximum password age, password warning period, and password inactivity period.

  2. Setting the minimum password age:

    To set the minimum number of days a user must wait before changing their password, use the -m or --mindays option followed by the number of days:

    sudo chage -m 7 username
    

    This command will set the minimum password age for the user username to 7 days.

  3. Setting the maximum password age:

    To set the maximum number of days a user can keep the same password before being forced to change it, use the -M or --maxdays option followed by the number of days:

    sudo chage -M 90 username
    

    This command will set the maximum password age for the user username to 90 days.

  4. Setting the password warning period:

    To set the number of days before a password expires that a user will receive a warning message, use the -W or --warndays option followed by the number of days:

    sudo chage -W 14 username
    

    This command will set the password warning period for the user username to 14 days.

  5. Setting the password inactivity period:

    To set the number of days after a password expires that a user can still log in, use the -I or --inactive option followed by the number of days:

    sudo chage -I 30 username
    

    This command will set the password inactivity period for the user username to 30 days.

  6. Setting the password expiration date:

    To set the exact date on which a user's password will expire, use the -E or --expiredate option followed by the date in the format YYYY-MM-DD:

    sudo chage -E 2023-12-31 username
    

    This command will set the password expiration date for the user username to December 31, 2023.

By following this tutorial, you should now have a good understanding of how to use the chage command in Linux to manage password aging policies for user accounts. By enforcing periodic password changes and setting appropriate warning and inactivity periods, administrators can enhance the security of user accounts and protect the system from unauthorized access.

  1. How to use chage command in Linux:

    • View and modify user account aging information.
    chage [options] username
    
  2. Changing password expiration with chage:

    • Set the maximum number of days a password is valid.
    chage -M 90 username
    
  3. Setting password aging policies in Linux:

    • Configure various password aging policies for a user.
    chage -m 7 -M 90 -I 30 -E "2024-12-31" username
    
  4. Viewing user account aging information with chage:

    • Display the current aging information for a user.
    chage -l username
    
  5. Disabling password expiration with chage:

    • Turn off password expiration for a user.
    chage -M -1 username
    
  6. Enforcing password change policies with chage:

    • Set the minimum number of days before a password can be changed.
    chage -m 3 username
    
  7. Configuring warning period for password expiry in chage:

    • Specify the number of days before a password expires that a warning is issued.
    chage -W 7 username
    
  8. Unlocking user accounts with chage command:

    • Unlock a user account that has been locked due to failed login attempts.
    chage -E -1 username
    
  9. Changing password aging settings for specific users:

    • Customize aging settings individually for users.
    chage -M 60 -W 10 user1