Skip to main content

Command Palette

Search for a command to run...

Simplifying Password Management with the chage Command in Linux :

Linux Password Aging Explained for Beginners :

Published
β€’4 min read
Simplifying Password Management with the chage Command in Linux :
R

A πŸš€ Passionate Linux and Cloud Computing Student . 🌐 Enthusiast in DevOps and System Administration πŸ§‘β€πŸ’».

Managing user accounts and ensuring the security of user passwords are critical tasks for any system administrator. One of the tools that Linux provides to help with this is the chage command, which is used for managing password aging. Password aging helps ensure that passwords are regularly updated, reducing the risk of compromised accounts.

What is Password Aging ?

Password aging is a system feature that forces users to change their passwords periodically. This is essential for maintaining security, as regular password changes can help prevent unauthorized access.

Key Concepts of Password Aging :

  • Minimum Password Age : The minimum number of days that must pass before a user can change their password again. This prevents users from changing their passwords too frequently.

  • Maximum Password Age : The maximum number of days a password can be used before the user is required to change it. This ensures passwords are updated regularly.

  • Warning Period : The number of days before a password expires that the user will receive a warning to change their password.

  • Inactive Period : The number of days after a password has expired before the account is locked.

  • Account Expiry : The date on which the user account will be disabled.

The chage Command :

The chage command is used to change the user password expiration information. It can set when users need to change their passwords and inform users of upcoming password expirations.

Basic Usage :

To check the password aging information for a user, you can use:

sudo chage -l username

Replace "username" with the name of the user you want to check.

Common Commands and Flags :

  1. View Password Aging Information :

     sudo chage -l username
    

    This displays the current password aging settings for the specified user.

  2. Set Minimum Password Age :

     sudo chage -m days username
    

    Replace "days" with the minimum number of days before the user can change their password again.

  3. Set Maximum Password Age :

     sudo chage -M days username
    

    Replace "days" with the maximum number of days a password can be used before it must be changed.

  4. Set Password Expiry Warning :

     sudo chage -W days username
    

    Replace "days" with the number of days before password expiration that the user will receive a warning.

  5. Set Account Inactivity Period :

     sudo chage -I days username
    

    Replace "days" with the number of days after password expiration before the account is locked.

  6. Set Account Expiry Date :

     sudo chage -E YYYY-MM-DD username
    

    Replace "YYYY-MM-DD" with the date on which the user account will be disabled.

  7. Force Password Change on Next Login :

     sudo chage -d 0 username
    

    This sets the last password change date to "0" days ago, forcing the user to change their password upon next login.

Example Workflow :

Let's go through an example of setting up password aging for a user named "johndoe" :

  1. Check Current Settings :

     sudo chage -l johndoe
    
  2. Set Minimum Password Age to 7 Days :

     sudo chage -m 7 johndoe
    
  3. Set Maximum Password Age to 90 Days :

     sudo chage -M 90 johndoe
    
  4. Set Password Expiry Warning to 14 Days :

     sudo chage -W 14 johndoe
    
  5. Set Account Inactivity Period to 30 Days :

     sudo chage -I 30 johndoe
    
  6. Set Account Expiry Date to December 31, 2024 :

     sudo chage -E 2024-12-31 johndoe
    
  7. Force Password Change on Next Login :

     sudo chage -d 0 johndoe
    

Conclusion :

Password aging is a crucial aspect of user management in Linux, helping to maintain security by ensuring that passwords are regularly updated. The chage command provides a straightforward way to manage password aging policies for users. By understanding and utilizing the various options and flags available with chage, system administrators can effectively enforce password policies and enhance the overall security of their systems.

If you have any questions or need further clarification, feel free to leave a comment below! Happy Linux-ing!

Thank You πŸ™β€οΈπŸ˜Š.

Linux Basics To Advance

Part 2 of 9

In This Series I Will Upload Linux Blogs From Basic To Advance. Stay TunedπŸ™β€οΈπŸ˜Š .

Up next

Simplified Linux User Management for Beginners :

Beginner-Friendly Tutorial: Using adduser, usermod, and groupadd in Linux :