Search This Blog

Sunday, 21 February 2021

Create a Linux user with expiration date

 Create a user named bandaru & Set expiry date to 2021-06-30

1) Create the user

[root@tomcathost01 ~]# useradd bandaru
[root@tomcathost01 ~]# passwd bandaru
Changing password for user bandaru.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

2) Check the expiry date for the user

[root@tomcathost01 ~]# chage -l bandaru
Last password change                                    : Feb 21, 2021
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7

3) Set the expiration date

[root@tomcathost01 ~]# chage -E 2021-06-30 bandaru

4) Validate the expiration date

[root@tomcathost01 ~]# chage -l bandaru
Last password change                                    : Feb 21, 2021
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : Jun 30, 2021
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7

No comments: