Saucepan

How to guides and technology tutorials for Amazon AWS, Google Cloud, Linux, macOS, Windows, and other systems

How to setup automatic account expiration on CentOS

Published: 06 March 2017
Updated: 29 April 2020
Filed Under: CentOS

If you need to grant access to a specific user but only for a few days, you can set their account to expire automatically after a specific date with the chage tool.

Set account expiration date

To set their account to expire, run the following command. Be sure to replace YYYY-MM-DD with the correct year, month, and day to expire on and username with the actual username.

sudo chage -E "YYYY-MM-DD" username

Remove account expiration

To disable the account from automatically expiring, you can run the following command. Be sure to replace username with the actual username.

sudo chage -E -1 username