4

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

# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes

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

/etc/default/useradd
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
someuser:x:1002:1002::/home/someuser:/bin/bash

$ groups someuser
someuser : someuser

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

GROUPS=wheel,dialout,tftp
DIR_MODE=1770

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.

Thanks

5
  • 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
    Commented Mar 25, 2015 at 20:15
  • @Bratchley: A more "correct" way would be to have a look into the source code, e.g. tinyurl.com/nvd62hq
    – FloHimself
    Commented Mar 25, 2015 at 20:23
  • What option have you tried in /etc/defaults/useradd that appears to be ignored?
    – JonathanS
    Commented Mar 25, 2015 at 21:59
  • I should have said /etc/default/useradd.
    – JonathanS
    Commented Mar 25, 2015 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
    Commented Mar 25, 2015 at 22:07

2 Answers 2

1

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.

0

Short answer: run useradd -D

This works with useradd from shadow.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .