How to set account expiration dates?

QuestionsQuestions4 SkillsProBasic Files OperationsSep, 16 2025
0211

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:

  1. Open a terminal.

  2. Run the following command, replacing YYYY-MM-DD with the desired expiration date and username with the name of the user:

    sudo usermod -e YYYY-MM-DD username
    

    For example, to set the expiration date for a user named "temporaryuser" to December 31, 2023, you would use:

    sudo usermod -e 2023-12-31 temporaryuser
    
  3. To verify that the expiration date has been set, you can use the chage command:

    sudo chage -l username
    

    This 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.

0 Comments

no data
Be the first to share your comment!