Introduction
chage is short for “Change Age”, which is used to view and edit password change time information, setting account status, change the expiry date of the account.
We must change password information regularly to ensure security, especially for administrators.
In this article, we will show you how to use the chage command in Linux in detail along with examples.
The syntax of chage command
$ chage [options] LOGIN
[options]
-l display the expiry information
For example, I want to check the expiry information of “ubuntu”:
$ chage -l ubuntu
Output:
-d change the expiry information
Now I want to specify the expiration date of “ubuntu” as of June 30, 2021:
$ sudo chage -d 2021-06-30 ubuntu
Then use chage command with -l option to check:
$ chage -l ubuntu
The expiry date has changed.
-E lock the account
$ sudo chage -E 2023-06-30 ubuntu
Then use chage command with -l option to check:
$ chage -l ubuntu
As you can see, my account will be locked on Jun 30, 2023.
-M set maximum time before the password can be changed.
I want to set the value as 365:
$ sudo chage -M 365 ubuntu
Then use chage command with -l option to check:
$ chage -l ubuntu
-I limit the date to change the password
I want to set the value as 30:
$ sudo chage -I 30 ubuntu
Then use chage command with -l option to check:
$ chage -l ubuntu
-W set a warning alarm
By default, it will warn 7 days in advance. I want to set the value as 3.
$ sudo chage -W 5 ubuntu
Then use chage command with -l option to check:
$ chage -l ubuntu
-h display help information
$ chage -h
Output:
Conclusion
The above article is a detailed guide on how to use the chage command in Linux.
Thank you for seeing.