chage command in Linux with examples
Last Updated :
13 Sep, 2024
The ‘chage’ command in Linux is a powerful tool used to manage user password expiry and account aging information. It is particularly useful in environments where user access needs to be controlled over time, such as when login access is time-bound or when it’s necessary to enforce regular password changes for security purposes. With the ‘chage’ command, administrators can view and modify password expiry details, set mandatory password change intervals, specify account expiration dates, and more.
Here we will walk you through the syntax, options, and practical examples of the ‘chage
‘ command.
What is the ‘chage’ command?
The ‘chage’ command, short for “change age,” allows system administrators to manage account aging parameters, including when a password was last changed, when it must be changed next, and when an account should be locked or warned about password expiration. This command is essential for maintaining security policies that require users to update their passwords periodically or limit the duration of user access.
Syntax:
chage [options] LOGIN
where,
- ‘[options]’: Flags that modify the behavior of the command.
- ‘LOGIN‘: The username of the account you want to modify.
In order to view the list of options that can be used with the chage command, use the help option:
chage -h
Output:

Common Options and Examples of ‘chage’ command in Linux
1. ‘-l’ option (List Account Aging Information)
Use this option to view the account aging information. In order to view the aging information of the root, use the keyword ‘sudo‘.
Input : sudo chage -l root
Output:

2. ‘-d’ option (Set Last Password Change Date)
Use this option to set the last password change date to your specified date in the command. In order to change the aging information of the root, use the keyword “sudo“. Further using the ‘-l’ option to view the changed date.
Input : sudo chage -d 2018-12-01 root
Output :

3. ‘-E’ option (Set Account Expiry Date)
Use this option to specify the date when the account should expire. In order to change the aging information of the root, use the keyword sudo. Further using the ‘-l’ option to view the changed date.
Input : sudo chage -E root
Output:

4. ‘-M’ and ‘-m’ option (Set Maximum and Minimum Password Age)
Use this option to specify the maximum and minimum number of days between password change. In order to change the aging information of the root, use the keyword ‘sudo’. Further using the ‘-l’ option to view the changed period.
Input : sudo chage -M 5 root
Output:

5. ‘-I’ option (Set Inactivity Period After Password Expiry)
Use this option to specify the number of days the account should be inactive after its expiry. It is necessary that the user should change the password after it expires, this command is useful when the user does not login after its expiry. Even after this inactivity period if the password is not changed then the account is locked and the user should approach the admin to unlock it.
In order to change the aging information of the root, use the keyword ‘sudo’. Further we used the ‘-l’ option to view the inactivity period.
Input : sudo chage -I 5 root
Output:

6. ‘-W’ option (Set Password Expiry Warning)
Use this option to give prior warning before the password expires.The input given in the command is the number of days prior to the expiry date when the warning should be given. In order to change the aging information of the root, use the keyword ‘sudo’. Further, using the ‘-l’ option to view the warning period.
Input : sudo chage -W 2 root
Output: 
Conclusion
The ‘chage’ command is a versatile and essential tool for Linux administrators tasked with managing user accounts and enforcing password policies. By understanding and utilizing the full range of options available with ‘chage’, administrators can effectively control access duration, enforce password changes, and maintain a secure environment.
Similar Reads
bzcmp command in Linux with examples
The bzcmp utility is used to invoke the cmp utility on bzip2 compressed files. All options specified are passed directly to cmp. As internally bzcmp calls cmp, We can pass the cmp command options to bzcmp. If only one file is specified, then the files compared are file1 and an uncompressed file1.bz2
2 min read
bzdiff command in linux with examples
bzdiff command in Linux is used to compare the bzip2 compressed files. Bzcmp and bzdiff are used to invoke the cmp or the diff program on bzip2 compressed files. All options specified are passed directly to cmp or diff. If only one file is specified, then the files compared are file1 and an uncompre
1 min read
bzgrep command in Linux with examples
bzgrep is a Linux command used to search for a pattern or an expression inside a bzip2-compressed file. This command simply passes it's arguments and the decompressed files to grep. Therefore, all the flags used in the grep command remain the same in bzgrep, since they are simply sent to grep as the
2 min read
bzip2 command in Linux with Examples
bzip2 command in Linux is used to compress and decompress the files i.e. it helps in binding the files into a single file which takes less storage space than the original file used to take. It has a slower decompression time and higher memory use. It uses Burrows-Wheeler block sorting text compressi
3 min read
bzless command in Linux with examples
bzless is a command similar to bzmore, but it has many more features. bzless does not have to read the entire input file before starting, so with a large file, it starts up faster than text editors like vi. bzless uses termcap (or terminfo on some systems), so it can run on a variety of terminals. S
2 min read
bzmore command in Linux with examples
bzmore command in Linux is used as a filter for CRT viewing of bzip2 compressed files, which are saved with .bz2 suffix. In simple words, using 'bzmore', the content of the file can be viewed on the screen without uncompressing the file. bzip2 is a block-sorting file compressor which compresses file
3 min read
cal command in Linux with Examples
The 'cal' command in Linux is a versatile tool that displays calendars directly in the terminal. If a user wants a quick view of the calendar in the Linux terminal, 'cal' is the command for you. Hereâs a look at the usage and features of 'cal' command in Linux. What is the 'cal' command?cal command
2 min read
case command in Linux with examples
The case command in Linux is an essential tool for simplifying script logic, especially when multiple if/elif conditions need to be evaluated for a single variable. It offers a more readable and efficient way to execute commands based on pattern matching, making your shell scripts easier to maintain
2 min read
How to View the Content of File in Linux | cat Command
The cat command in Linux is more than just a simple tool, it's a versatile companion for various file-related operations, allowing users to view, concatenate, create, copy, merge, and manipulate file contents. Let's see the details of some frequently used cat commands, understanding each example alo
7 min read
cc command in Linux with Examples
'cc' command stands for C Compiler, usually an alias command to 'gcc' or 'clang'. As the name suggests, executing the 'cc' command will usually call the 'gcc' on Linux systems. It is used to compile the C language codes and create executables. The number of options available for the cc command is ve
3 min read