Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to control account expiration time in linux

Shulou Source: shulou.com Published: 2022-06-01 14:46:31 10月03日 Update

Linux how to control account expiration time, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Law 1: useradd oldboy-e 01amp 28 Universe 12 when adding a user

Or modify the parameters of the following file:

[root@oldboy skel] # grep EXPIRE / etc/default/useradd

EXPIRE=

Example 7: specify parameters to execute useradd-D-e

[root@oldboy ~] # date +% F

2012-01-25

[root@oldboy ~] # useradd-D-e 01Universe 19 # → modifies the default new account expiration time, after which all new users will expire.

[root@oldboy ~] # useradd-D | grep EXPIR # → modification has been effective.

EXPIRE=01/19/12

[root@oldboy ~] # useradd tmpuser3 # → add user tmpuser3. Note that the-e parameter is not added.

[root@oldboy ~] # chage-l tmpuser3 # → to check the account expiration time.

Last password changed: January 24, 2012

Password expiration time: never

Password expiration time: never

Account expiration time: January 19, 2012 # → is the modified default expiration time.

The minimum number of days between two password changes: 0

The maximum number of days between two password changes: 99999

Number of days to warn before password expiration: 7

[root@oldboy ~] # useradd-D-e "" # → restore after testing

[root@oldboy] # useradd-D

GROUP=100

HOME=/home

INACTIVE=-1

EXPIRE= # → restored

SHELL=/bin/bash

SKEL=/etc/skel

CREATE_MAIL_SPOOL=yes

Special note: only the default value of the configuration file has been changed, and it only takes effect for new users who are established later, not for old users.

When changing a user:

Method 2: modify the account attribute usermod-e 01qq28x12 oldboy

Method 3: adjust account expiration chage-E 01max 28x12 oldboy

View account expiration: chage-l oldboy

The configuration can be scripted by passing a time parameter at each stage.

Make our work more standardized and professional!

Note:

C5.8 the expiration time will be postponed by 2 days on the set date.

C6.4 the expiration time will be postponed by 1 day on the set date.

After reading the above, have you mastered how to control the expiration time of your account in linux? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Time account password user parameter days control between never content file method date more account problem configuration maximum minimum helpless Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Huawei Shulou Information Docker vpn