Usually we will set the Linux system account related information, but many users will set the validity period of the account, and the account validity period is mainly used in enterprises. What should you do if the account expires in the Linux system? Here are the following steps: Tips for extending the validity period of your Linux account.
Method 1: When adding users
useradd linuxidc -e 01/28/12
Or modify the parameters of the following files:
[root@linuxidc skel]# grep EXPIRE /etc/default/useradd
EXPIRE=
Example: Execute useradd -D -e with specified parameters
[root@linuxidc ~]# date +%F
2012-01-25
[root@linuxidc ~]# useradd -D -e 01/19/12 #→Modify the default expiration time for new accounts. After setting, new users will expire after this time.
[root@linuxidc ~]# useradd -D|grep EXPIR #→The modification has taken effect.
EXPIRE=01/19/12
[root@linuxidc ~]# useradd tmpuser3 #→Add user tmpuser3. Note that the -e parameter is not added.
[root@linuxidc ~]# chage -l tmpuser3 #→View account expiration time.
Last password change time: January 24, 2012
Password expiration time: Never
Password expiration time: Never
Account expiration time: January 19, 2012 #→ is the modified default expiration time.
Minimum number of days between password changes: 0
Maximum number of days between password changes: 99999
Number of days to warn before password expires: 7
[root@linuxidc ~]# useradd -D -e “” #→Restore after testing
[root@linuxidc ~]# useradd -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE= #→Restored
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
Special note: This only changes the default value of the configuration file, which will only take effect for new users created later, and has nothing to do with old users.
When changing users:
Method 2: Modify account attributes
usermod -e 01/28/12 linuxidc
Method 3: Adjust account expiration
chage -E 01/28/12 linuxidc
View account expirations:
chage -l linuxidc
The configuration can be scripted by passing a time parameter at each stage.
Make our work more standardized and professional!
Note: The expiration date is postponed by 2 days on the set date, and does not expire on the same day.
The above is an introduction to the solutions to Linux account expiration. This article introduces three solutions. You can solve this problem by modifying the account attributes or adjusting the expiration time.