Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to control account expiration time in linux

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report