First off, the respective man page snippets highlight the differences between the two commands and give some indication of what is going on. For
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 default choosing Debian policy conformant UID and GID values, creating a home directory with skeletal configuration, running a custom script, and other features.
useradd is a low level utility for adding users. On Debian, administrators should usually use adduser(8) instead.
Further investigation of
reveals that it is a perl script providing a high level interface to, and thus offering some of the functionality of, the following commands:
– used to add/change users passwords.
– used to add/change group passwords.
– used to change various user associated parameters.
– used to add/change additional information held on a user.
– used to change password expiry information.
– used to change disk usage quotas.
A basic run of the
command is as follows:
This simple command will do a number of things:
- Create the user named
- Create the user’s home directory (default is
and copy the files from/etc/skel
- Create a group with the same name as the user and place the user in it.
- Prompt for a password for the user.
- Prompt for additional information on the user.
program can most of accomplish most of this, however it does not do so by default and needs additional options. Some of the information requires more commands:
useradd -m -U username
ensures that created UIDs and GIDs conform with the Debian policy. Creating normal users with
seems to be ok, provided
matches the Debian policy. What is a problem though is that Debian specifies a particular range for system user UIDs which only seems to be supported in
, so naively adding a system user with
and not specifying a UID/GUID in the correct range leaves the potential for serious problems.
Another common use for
is to simplify the process of adding a user to a group. Here, the following command:
adduser username newgroup
replaces a more complex
command that requires the groups which the user is already a member of (and that you would like the user to remain a member) to be specified:
usermod -G all,other,groups,user,is,in,newgroup
One downside to using
here though is that you can only specify one group at a time.