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
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.
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.
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.
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.
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.
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.
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.
How to use chage
command in Linux:
chage [options] username
Changing password expiration with chage
:
chage -M 90 username
Setting password aging policies in Linux:
chage -m 7 -M 90 -I 30 -E "2024-12-31" username
Viewing user account aging information with chage
:
chage -l username
Disabling password expiration with chage
:
chage -M -1 username
Enforcing password change policies with chage
:
chage -m 3 username
Configuring warning period for password expiry in chage
:
chage -W 7 username
Unlocking user accounts with chage
command:
chage -E -1 username
Changing password aging settings for specific users:
chage -M 60 -W 10 user1