Always use adduser (and deluser when deleting users) when you're creating new users from the command line. (If you're writing a script, especially if you aim for portability, you might want to use the lowlevel utilities instead – and adduser/deluser might not be available on all distros, e.g. on SuSE.)
The useradd, userdel and usermod commands are lowlevel utilities which are there for historical reasons, while adduser/deluser Do The Right Thing™. (I remember which to use by thinking that user* comes after adduser/deluser in the alphabet, and therefore is "worse".)
According to the respective manpages (on Ubuntu 12.04 Precise Pangolin, i.e. a Debian derivative system).
Manpage for adduser says:
(Emphasis added.)
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.
adduser and addgroup can be run in one of five modes:
Manpage for useradd says:
useradd is a low level utility for adding users. On Debian, administrators should
usually use adduser(8) instead.
Another couple of differences, that lead to specific scenarios where useradd might be preferable.
In some newer distros, including Ubuntu 14.4, adduser will prompt for information such as password and "gecos" (data for the finger command). This means it can be less suitable for calling from a script (credit: already mentioned in a comment by Wernight).
The prompts can be suppressed by passing null arguments:
adduser --disabled-password --gecos "" USER
useradd allows you to pass multiple additional groups to add a user to by means of the -G option. adduser seems to require that you call the command once for each group to add.
adduser is friendlier in that it sets up the account's home folders and other settings (e.g. automatically loading system stats and notifications on login), whereas useradd just creates the user.
Basic difference is "adduser" will create home directory & add skeleton files to that directory where "useradd" wont create any home directory & skeleton files !
adduser try :
Adding user `try' ...
Adding new group `try' (1001) ...
Adding new user `try' (1001) with group `try' ...
Creating home directory `/home/try' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for try
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
useradd try1 :
# ll /home/
total 20
drwxr-xr-x 5 root root 4096 Oct 26 15:52 ./
drwxr-xr-x 22 root root 4096 Oct 26 15:47 ../
drwx------ 8 ashishk ashishk 4096 Oct 26 15:50 ashishk/
drwxr-xr-x 3 root root 4096 Oct 14 13:02 .ecryptfs/
drwxr-xr-x 2 try try 4096 Oct 26 15:52 try/
root@chef-workstation:/home/ashishk#
I'll also point out that adduser does not always have the -M option and also does not respect the --system flag which specifically says:
Note that useradd will not create a home directory for such an user, regardless of the default setting in /etc/login.defs (CREATE_HOME). You have to specify the -m options if you want a home directory for a system account to be created.
If you're trying to create a system user without a home directory then use useradd --system -M.
Source: What's the difference between “adduser” and “useradd”?
Always use
adduser
(anddeluser
when deleting users) when you're creating new users from the command line. (If you're writing a script, especially if you aim for portability, you might want to use the lowlevel utilities instead – andadduser
/deluser
might not be available on all distros, e.g. on SuSE.)The
useradd
,userdel
andusermod
commands are lowlevel utilities which are there for historical reasons, whileadduser/deluser
Do The Right Thing™. (I remember which to use by thinking thatuser*
comes afteradduser/deluser
in the alphabet, and therefore is "worse".)According to the respective manpages (on Ubuntu 12.04 Precise Pangolin, i.e. a Debian derivative system).
Manpage for
adduser
says:(Emphasis added.)
Manpage for
useradd
says:See also: What's the difference between “adduser” and “useradd”? (on SuperUser)
adduser
: add user with full profile and info (pass, quota, permission, etc.)useradd
: add user with his name only (if you want to add a temp user with only a name,other info not required)Another couple of differences, that lead to specific scenarios where useradd might be preferable.
In some newer distros, including Ubuntu 14.4, adduser will prompt for information such as password and "gecos" (data for the finger command). This means it can be less suitable for calling from a script (credit: already mentioned in a comment by Wernight).
The prompts can be suppressed by passing null arguments:
useradd
allows you to pass multiple additional groups to add a user to by means of the-G
option.adduser
seems to require that you call the command once for each group to add.adduser
is friendlier in that it sets up the account's home folders and other settings (e.g. automatically loading system stats and notifications on login), whereasuseradd
just creates the user.Basic difference is "adduser" will create home directory & add skeleton files to that directory where "useradd" wont create any home directory & skeleton files !
adduser try :
useradd try1 :
The biggest different between using
adduser
anduseradd
is:adduser
command, the home folder for the user will be created as default.useradd
command, there is no home folder for the user.So I suggest you to use
adduser
instead of usinguseradd
.I'll also point out that
adduser
does not always have the-M
option and also does not respect the--system
flag which specifically says:If you're trying to create a system user without a home directory then use
useradd --system -M
.