How to set default account-expiration date for all new users?

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-22

and to list the new defaults:

adduser -D

Worked in Centos7

2

From 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.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like