Adduser and Addgroup Commands
Adduser and Addgroup Commands
Description
adduser and addgroup add users and groups to the system according to command line options and
configuration information in /etc/adduser.conf. They are friendlier front ends to the low-level tools
like useradd, groupadd and usermod programs, by choosing policy-conformant UID and GID values,
creating a home directory with skeletal configuration, running a custom script, and other features.
adduser and addgroup can be run in one of five modes:
(The same applies to the variable DEBUG, but DEBUG is deprecated and will be removed in a later
version of adduser).
Do not run passwd to set the password. The user won't be able to use her
--disabled-login
account until the password is set.
Like --disabled-login, but logins are still possible (for example using SSH RSA
--disabled-password
keys), but not using password authentication.
By default, user and group names are checked against the configurable regular
expression NAME_REGEX (or NAME_REGEX_SYSTEM if --system is
--force-badname
specified) specified in the configuration file. This option forces adduser and
addgroup to apply only a weak check for validity of the name.
Set the gecos field for the new entry generated. adduser will not ask for finger
--gecos GECOS
information if this option is given.
When creating a group, this option forces the new groupid to be the given
--gid ID
number. When creating a user, this option will put the user in that group.
When combined with --system, a group with the same name and ID as the
system user is created. If not combined with --system, a group with the given
--group
name is created. This is the default action if the program is invoked as
addgroup.
Use DIR as the user's home directory, rather than the default specified by the
--home DIR configuration file. If the directory does not exist, it is created and skeleton files
are copied.
Use SHELL as the user's login shell, rather than the default specified by the
--shell SHELL
configuration file.
Add the new user to GROUP instead of a user group or the default group
--ingroup GROUP defined by USERS_GID in the configuration file. This affects the users primary
group. To add additional groups, see the add_extra_groups option.
Be verbose, which is most useful if you want to nail down a problem with
--debug
adduser.
--system Create a system user or group.
Force the new userid to be the given number. adduser will fail if the userid is
--uid ID
already taken.
Override the first uid in the range that the uid is chosen from (overrides
--firstuid ID
FIRST_UID specified in the configuration file).
--lastuid ID Override the last uid in the range that the uid is chosen from ( LAST_UID ).
--add_extra_groups Add new user to extra groups defined in the configuration file.
Configuration
The file /etc/adduser.conf contains defaults for the programs adduser, addgroup, deluser and
delgroup. Each line holds a single value pair in the form "option = value". Double or single quotes are
allowed around the value, as is whitespace around the equals sign. Comment lines must have a hash
sign ("#") in the first column.
The valid configuration options are:
DSHELL The login shell to be used for all new users. Defaults to /bin/bash.
If this is set to yes, then the home directories created will have an extra
LETTERHOMES directory inserted that is the first letter of the loginname. For example:
/home/u/user. Defaults to no.
The directory from which skeletal user configuration files should be copied.
SKEL
Defaults to /etc/skel.
FIRST_SYSTEM_GID
specify an inclusive range of GIDs from which system GIDs can be
,
dynamically allocated. Default to 100 - 999.
LAST_SYSTEM_GID
FIRST_GID, specify an inclusive range of GIDs from which normal group's GIDs can be
LAST_GID dynamically allocated. Default to 1000 - 29999.
If this is set to yes, then each created user will be given their own group to
USERGROUPS use. If this is no, then each created user will be placed in the group whose
GID is USERS_GID (see below). The default is yes.
If set to a valid value (e.g., 0755 or 755), directories created will have the
DIR_MODE
specified permissions as umask. Otherwise, 0755 is used as default.
If this is set to yes, then home directories for users with their own group (
USERGROUPS=yes ) will have the setgid bit set. This was the default
SETGID_HOME setting for adduser versions previous to 3.13. Unfortunately, it has some bad
side effects, so we no longer do this per default. If you want it nevertheless
you can still activate it here.
If set to a nonempty value, new users will have quotas copied from that user.
QUOTAUSER
The default is empty.
User and group names are checked against this regular expression. If the
name doesn't match this regexp, user and group creation in adduser is refused
NAME_REGEX unless --force-badname is set. With --force-badname set, only weak checks
are performed. The default is the most conservative ^[a-z][-a-z0-9]*$. When
--system is specified, NAME_REGEX_SYSTEM is used instead.
Files in /etc/skel/ are checked against this regex, and not copied to the newly
SKEL_IGNORE_REG created home directory if they match. This is by default set to the regular
EX expression matching files left over from unmerged config files (dpkg-(old|
new|dist)).
Setting this to something other than 0 (the default) will cause adduser to add
ADD_EXTRA_GROU
newly created non-system users to the list of groups defined by
PS
EXTRA_GROUPS (below).
This is the list of groups that new non-system users will be added to. By
EXTRA_GROUPS
default, this list is 'dialout cdrom floppy audio video plugdev users games'.
Exit values
The user exists as specified. This can have 2 causes: The user was created by adduser or the user
0 was already present on the system before adduser was invoked. If adduser was returning 0,
invoking adduser a second time with the same parameters as before also returns 0.
Creating the user or group failed because it was already present with other UID/GID than specified.
The username or groupname was rejected because of a mismatch with the configured regular
expressions. adduser has been aborted by a signal.
1
Or this code may be returned for other undocumented reasons, which in that case are printed to
console. You may then consider to remove --quiet to make adduser more verbose.
Files
/etc/adduser.conf Default configuration file for adduser and addgroup
Creates the user account mynewuser, and creates their home directory at the location
/home/mynewuserhome.