My /etc/default/useradd file is as follow:

# useradd defaults file

man page for useradd provides many obvious options for when I use the useradd binary.
It also says in the man page:

Default values for account creation.

But it doesn't specify what values are valid within this file. I have tried using the options for the useradd binary in this file but they seem to be ignored.

2015/04/02 Update: So I should probably do some clarifications:
I am used to the debian style useradd and adduser

I'm working now, in a CentOS system and there really only is useradd. The whole point in any of this work is to modify the base user creation for a standard practice, by default:

$ sudo useradd someuser

$ cat /etc/passwd

$ groups someuser
someuser : someuser

I was hoping that I could just modify /etc/default/useradd to set some basics like:


But these sorts of mods to the /etc/default/useradd file are just ignored. I could just write some simple bash script to feed useradd the defaults, but would rather not if there's just some simple config I am overlooking.


  • I was able to get a fairly complete list of options by looking at the output of strings /usr/sbin/useradd but there's probably a more direct and "correct" way of doing it than that. – Bratchley Mar 25 '15 at 20:15
  • @Bratchley: A more "correct" way would be to have a look into the source code, e.g. tinyurl.com/nvd62hq – FloHimself Mar 25 '15 at 20:23
  • What option have you tried in /etc/defaults/useradd that appears to be ignored? – JonathanS Mar 25 '15 at 21:59
  • I should have said /etc/default/useradd. – JonathanS Mar 25 '15 at 22:05
  • I think those are default values you can set. Just rename file /etc/default/useradd and run useradd -D. You will see the same keys and almost the same values. – taliezin Mar 25 '15 at 22:07

Under Debian 8, useradd is under passwd. I have version 4.2-3 installed. useradd(8) man page provides each option and how it is set on the command line and where if any place it is set in a configuration file, typically this in /etc/default/useradd. USERGROUPS_ENAB for example is specified in /etc/login.defs, not /etc/default/useradd. Defaults are given in the man page along with the value types and/or values the option can take.

For example:

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

'useradd -D' from the man page outputs your defaults.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.