Open In App

Creating a User With an Expiry Date in Linux

Improve
Improve
Like Article
Like
Save
Share
Report

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. 


Last Updated : 22 Jun, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads