617

What is the difference between the commands adduser and useradd on Ubuntu?

3
  • 20
    Same question on Super User and on Server Fault
    – ændrük
    Sep 15, 2013 at 20:37
  • 8
    and also on Unix stackexchange (quite detailed answer)
    – xealits
    Oct 11, 2016 at 22:17
  • 3
    and it is and stays a good, valid question. The issue is not people asking it in respective contexts, it is that this question needs to be asked at all.
    – foo
    Dec 19, 2018 at 15:36

10 Answers 10

543

useradd is native binary compiled with the system. But, adduser is a perl script which uses useradd binary in back-end.

adduser is more user friendly and interactive than its back-end useradd. There's no difference in features provided.

also adduser is a wrapper for useradd.

Source: What's the difference between “adduser” and “useradd”?

9
  • 82
    useradd with the -m option will create the home directory.
    – richsinn
    Aug 8, 2014 at 0:02
  • 13
    The implimentation isn't that interesting, the semantics are. Like adduser(8) is more userfriendly and creates and set up a user by default the way you expect. And useradd(8) only do what you ask, so do you want a home directory created, you have to tell it to create it for you.
    – Anders
    Sep 22, 2014 at 14:14
  • 40
    I have to google this every time... How can I help myself remember which is which? Jan 22, 2016 at 20:10
  • 16
    @kkhugs to me "adduser" feels the most intuitive because it's a command that sounds like english, while the other does not, semantically. If you remember it as the "most intuitive" of the two, you can also try to remember it as the preferred/easier one.
    – pzkpfw
    May 1, 2016 at 10:41
  • 7
    under Red Hat /usr/sbin/adduser -> useradd .. sheesh ...
    – Levon
    Aug 2, 2017 at 1:08
201

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.

See also: What's the difference between “adduser” and “useradd”? (on SuperUser)

7
  • 10
    I never can remember which one, so this is my stupid mnemonic if it helps anyone :) "user" rhymes with "loser", and "loser" comes last. Thus: adduser, deluser. Mar 13, 2015 at 12:27
  • 44
    I actually disagree on "Always user adduser": For automated scripts I'd prefer useradd because it's always there, non-interactive, and not distro-specific.
    – Wernight
    Apr 15, 2015 at 10:47
  • 2
    I tried adduser on openSUSE, and it's not there.(13.2)
    – cst1992
    May 24, 2016 at 7:18
  • 3
    @cst1992 You're right, I've edited the answer to reflect this. Curiously enough, when I tried locate adduser on a SuSE 11 system at work I found that there was an adduser manpage, but no binary (and neither a deluser manpage nor a command).
    – zrajm
    May 24, 2016 at 15:40
  • 5
    On Red Hat /usr/sbin/adduser -> useradd
    – Levon
    Aug 2, 2017 at 1:10
25

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)

1
  • 5
    +1 and Welcome! I up voted the person who was incapable of explaining their previous down vote. Keep it up! Good programmers always rise to the top - (and don't down vote without an explanation). :)
    – Ricalsin
    Aug 9, 2014 at 2:38
12

Another couple of differences, that lead to specific scenarios where useradd might be preferable.

  1. 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
    
  2. 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.

1
  • Doesn't work on ubuntu 16.04. Feb 10, 2017 at 0:55
8

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.

3
  • 4
    Wrong. useradd can create home directory with -m, set password with -p, create skeleton files with -k, and add user to group(s) with -G.
    – ychaouche
    Feb 21, 2018 at 11:38
  • 3
    @ychaouche Theres a difference between "will create [...]" and "can create [...]".
    – thoerni
    May 24, 2021 at 11:55
  • Same difference as using a command with default options and using a command with desired options.
    – ychaouche
    May 24, 2021 at 13:27
7

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#
1
2

The biggest different between using adduser and useradd is:

  • With adduser command, the home folder for the user will be created as default.
  • With useradd command, there is no home folder for the user.

So I suggest you to use adduser instead of using useradd.

0

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.

0

Specifically, with useradd you should be more explicit as it doesn't e.g. create a home directory,you should use the -m option or the -p to set a password. Also another main difference is that useradd has different settings from adduser e.g. set a different shell for the user. In most distros useradd sets usr/bin/sh while adduser sets usr/bin/bash

-1

The adduser interactive way to creates accounts and pwd with single command. Which can be only found in the Debian family distros.

Both adduser & useradd do the same functionality; with few differences in favour of adduser.

When creating a user with adduser it will automatically encrypt the user home directory ( with permission of 755 ).

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Nov 21, 2022 at 3:37

You must log in to answer this question.

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