What's the difference between useradd
and adduser
? When/why should I prefer using one or the other?
- 27,262
- 12
- 53
- 108
- 909
- 1
- 8
- 11
-
6What operating system are you referring to? – mfinni Jan 05 '11 at 14:39
-
3Also - http://www.catb.org/~esr/faqs/smart-questions.html – mfinni Jan 05 '11 at 14:39
-
http://linux.die.net/man/8/adduser http://linux.die.net/man/8/useradd – Zoredache Jan 05 '11 at 17:24
-
This is a **`Debian Linux`** based question. – unixman83 Mar 02 '12 at 18:45
-
Same question on [Ask Ubuntu](http://askubuntu.com/questions/345974/what-is-the-difference-between-adduser-and-useradd/381646#381646) and on [Super User](http://superuser.com/questions/547966/whats-the-difference-between-adduser-and-useradd). – zrajm Dec 05 '13 at 09:39
5 Answers
In the case of Debian and its related distros, adduser is a friendlier interactive frontend to useradd.
- 60,515
- 14
- 113
- 148
- 3,859
- 19
- 17
-
8It is not about friendliness, it's about usage. You can use adduser for interactively adding an account or you can use useradd for batch adding accounts. useradd has also an interactive mode. – tkorkunckaya Sep 26 '12 at 09:49
-
@tkorkunckaya: so what usage based on your description then if useradd can also do interactive mode? – László Papp Jun 19 '14 at 09:48
-
Always use adduser
(and deluser
when deleting users).
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
andaddgroup
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 likeuseradd
,groupadd
andusermod
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
andaddgroup
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 useadduser(8)
instead.
See also:
- What's the difference between “adduser” and “useradd”? (on SuperUser)
- What is the difference between
adduser
anduseradd
? (on Ask Ubuntu).
-
Agree with that, "Always use adduser" over useradd. This should be the accepted answer ! – TwystO Aug 16 '16 at 18:27
On Ubuntu, useradd simply creates an entry in the user database (/etc/passwd etc.).
adduser on the other hand also creates a home directory for the user, populates it with the content of /etc/skel and lets you set the password interactively.
- 60,515
- 14
- 113
- 148
- 411
- 2
- 7
-
3+1. man useradd : "useradd is a low level utility for adding users. On Debian, administrators should usually use adduser(8) instead." – petrus Jan 05 '11 at 15:41
-
-
-
useradd can create the home directory, set password, add to groups, create skeleton files and even set the shell. – ychaouche Feb 21 '18 at 12:37
lrwxrwxrwx. 1 root root 7 Nov 17 13:52 /usr/sbin/adduser -> useradd
One is a "shortcut" / "symbolic link" to the other. So no difference.
This is on redhat linux (and centos / fedora), it may not hold true on other distros.
- 5,447
- 2
- 32
- 54
-
3
-
-
4Many binaries and scripts alter their behavior based on the command line invocation. – jscott Jan 05 '11 at 15:15
On FreeBSD:
adduser
is a "friendly" interactive Q&A way to add local users.
useradd
doesn't exist.
- 77,337
- 11
- 120
- 212