How to set expiry date for the user account in linux?

Giving expiry date to the user account in linux helps to ensure the user account will not be used to login after a specific period. But, the files or directories created by the user be available on the system until manual deletion.

Prerequisites:

1. Sudo access user account.

Things to mind before setting expiry date for the user account.

  1. Confirm the hostname of the system using hostname command.
Here are the steps to set an expiry date for the user account in linux.

Step 1 : Check the present status of the user account using below command.

sudo chage –l <username>

Step 2 : Execute below command to set an expiry date for user account.

sudo usermod –e YYYY-MM-DD <username> 

Step 3 : Now, Verify the account status using the command shown in Step 1.

Note :

1.Password expire denotes the user’s password will expire after some period of time, once the password expired, user has to set new password.
2. User account expire denotes the user cannot login into the system after the user account expire date.

How do you feel about this post? Drop your comments below..