chage Command Examples in Linux

chage is a command-line utility in Linux that is used to modify the password aging information for user accounts. Password aging is a security feature that allows you to specify how often users must change their passwords and how long their passwords are valid before they expire.

To modify the password aging information for a user account using chage, you can use the following command syntax:

# chage -M [days] -W [days] [username]

This command will set the maximum number of days that a password is valid to [days] and the number of days before a password must be changed to [days] for the user account [username]. For example, to set the maximum password age to 90 days and the password warning period to 7 days for the user john, you can use the following command:

# chage -M 90 -W 7 john

chage includes many other options and arguments that allow you to customize the password aging information for user accounts. For example, you can use the -d option to specify the date when the password was last changed, or the -I option to specify the number of inactive days after which a user’s password will expire.

For more information on using chage, you can consult the chage documentation or use the chage –help command to view a list of available options and usage examples.

chage Command Examples

1. List password information for the user:

# chage --list username

2. Enable password expiration in 10 days:

# chage --maxdays 10 username

3. Disable password expiration:

# chage --maxdays -1 username

4. Set account expiration date:

# chage --expiredate YYYY-MM-DD username

5. Force user to change password on next log in:

# chage --lastday 0 username
Related Post