chage Command in Linux
Transform Your Career
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
Overview
The chage command in Linux is a potent utility used to manage and control password aging for user accounts. As a system administrator, understanding the chage command in Linux is crucial for managing user security policies effectively. This command offers the ability to set the lifespan of a password and to decide when a password must be changed.
Syntax of chage Command in Linux
The basic syntax of the chage command in Linux is as follows:
Where:
- options: These are flags or parameters that determine how the chage command will function.
- USER_NAME: The username for which you want to modify the password aging settings.
Options in chage command in Linux
-
-l, --list: Lists the current password aging settings for the user.
For example -
Output:
This command lists all password aging information for 'username'.
-
-E, --expiredate: Sets the date when the user account will be disabled.
For example -
This command sets the expiration date for 'username' to December 31, 2023.
-
-M, --maxdays: Sets the maximum number of days during which a password is valid.
For example -
This command sets the maximum number of days the password of 'username' will remain valid to 60 days.
Scaler Placement Report and Statistics
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
Example Usages
-
Check the current password aging settings:
Output:
Explanation: This usage shows the current password aging settings for 'username'.
-
Change the maximum password age:
Explanation: This usage sets the maximum password age for 'username' to 90 days.
Tips
-
The chage command must be executed with root or sudo privileges.
-
It is a good practice to regularly review and enforce password aging policies to maintain system security.
Turn Learning into Career Growth
Advanced Use Cases of chage Command in Linux
-
Set a warning period for password expiry:
Explanation: This command will set a warning period of 7 days before the 'username' password expires.
-
Set the minimum password age:
Explanation: This command sets the minimum password age for 'username' to 5 days.
-
Make a password never expire:
Explanation: This command sets the maximum number of days between password changes to -1, indicating that the 'username' password will never expire.
Conclusion
-
The chage command in Linux is an effective tool for managing password aging policies.
-
It can be used to list current settings, set expiration dates, and control password lifespan.
-
Regular use of the chage command is an essential part of good system security practice.




