Creating a User With an Expiry Date in Linux

Linux is a multi-user system and thus, it allows more than one person to interact with the system at the same time. There are numerous ways in which we can create new users in Linux. The system administrator has the responsibility to manage different users of the system.  For types of users in Linux refer Users in Linux System Administration

User accounts with an expiration date provide a facility to create a user account for temporary use. Let’s discuss how to create a user with an expiry date in Linux. 

Syntax: 

$ sudo useradd -e YYYY-MM-DD username

In the above command:

  • useradd is a command used to add a new user account. 
  • -e YYYY-MM-DD specifies the expiry date for a new user account. 

Let us create a new user with Username: Test and Expiry Date: June 10 2020.In order to create a new user execute the following command in terminal. 



sudo useradd -e 2020-06-10 Test

In order to login as a newly created user, a password needs to set up. Thus, we use paswd command. To set a new password execute the following command in the terminal. 

sudo passwd Test

Once the command executes a prompt will ask to set a new password. 
 

To verify the user account expiration details we can use chage command.To get the details, execute the following command in the terminal. 
 

sudo chage -l Test

Thus, in this way, we can create a new user account with an expiration date. 

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.