To set account expiration dates for a user in Linux, you can use the usermod command with the -e option. Here’s how to do it:
Open a terminal.
Run the following command, replacing
YYYY-MM-DDwith the desired expiration date andusernamewith the name of the user:sudo usermod -e YYYY-MM-DD usernameFor example, to set the expiration date for a user named "temporaryuser" to December 31, 2023, you would use:
sudo usermod -e 2023-12-31 temporaryuserTo verify that the expiration date has been set, you can use the
chagecommand:sudo chage -l usernameThis will display the account aging information, including the expiration date.
Make sure to replace username with the actual username of the account you are modifying.
