How can I set a default account-expiration-date for all new users?
I know we can do it for every new added user with the --expiredate, but I want that it is default and done for every new user!
like when I use adduser someuser and then I type chage -l someuser I want to find directly that the account expires after one year from the adding-day!
'
Many thanks for your help!
2 Answers
You can use option -D to edit the default expiry date from command line:
adduser -D --expiredate=2020-12-22and to list the new defaults:
adduser -DWorked in Centos7
2From useradd man page:
-e, --expiredate EXPIRE_DATE The date on which the user account will be disabled. The date is specified in the format YYYY-MM-DD. If not specified, useradd will use the default expiry date specified by the EXPIRE variable in /etc/default/useradd, or an empty string (no expiry) by default.So you should change the EXPIRE variable in the /etc/default/useradd to whatever value you like. The same applies for adduser that uses useradd in the background.