In most Linux systems, when you want to create a new user, you have two options: adduser
or useradd
.
So, what exactly is the difference between the two? Is one of them superior to the other? Which should you choose? Is it useradd
or adduser
?
Let’s break it down.
Useradd
: Low-Level Utility
useradd
is a built-in Linux command that is available on all Linux systems. It’s a low-level utility, meaning it’s more manual and less interactive. Creating new users with this command is a time-consuming task because it does not automatically create the home directory and user password.
Adduser
: High-Level Alternative
The adduser
command is not a standard binary. It’s typically a Perl script or a wrapper that uses useradd
in the background. Some distros don’t include it at all, while others symlink it to useradd
.
Despite this, adduser
is a much more user-friendly option. It walks you through the user creation process interactively — asking for a password, setting up a home directory, and configuring default shell and group settings.
Creating a User with useradd
Let's start with a look at the useradd
command's default behavior. Execute the below command:
$ useradd coffeescripts
Looking at the /home
directory after successfully executing the above command, you will notice that the home directory for the user coffeescripts
hasn't been created.
$ ls /home
Creating a User with adduser
Unlike useradd
, which requires extra flags to set everything up, adduser
handles most of it for you interactively.
When you run:
$ adduser username
You’ll be prompted to enter a password and a few optional details like full name and contact info. Once completed, the system automatically:
Creates the user account
Generates the home directory
Sets up the default shell
Assigns the user to a group
This command also respects default settings defined in /etc/login.defs
, making it more convenient and consistent for user management.
Even the man page on Debian-based systems recommends adduser
over useradd
for everyday use.
To confirm it worked, list the contents of /home
and you’ll see that the new user’s directory has been created:
$ ls /home
Reproducing adduser
Behavior with useradd
To achieve nearly the same result as adduser
by using the low-level utility useradd
, the command would look like this:
$ sudo useradd -d /home/coffeaddicts -m -s /bin/zsh -p secretpass -c "FullName,Phone,Other Information"
It is also important to know that you can omit the -c
option if you don't wish to add user information.
Useful adduser
Options
The adduser
command provides you with a number of options. Here’s a short list of the most important ones. For more information, see the help or man pages:
--system
– Create a new system user. System users are automatically assigned to thenogroup
group. Use the--gid
or--ingroup
options to add a system user to an existing group.--home DIR
– UseDIR
instead of the default home directory. If necessary, the directory will be created and skeleton files copied.--shell SHELL
– UseSHELL
instead of the default.--ingroup GROUP
– Set the primary group of the user toGROUP
.--add_extra_groups
– Add the new user to a configuration-defined extra group.
Configuring Defaults for adduser
If you want to customize how adduser
behaves each time you create a user, you can tweak its configuration file:
/etc/adduser.conf
This file controls the default values used during user creation. It's well-commented, so it's easy to understand and modify. Some of the key settings you can configure include:
Default shell — Set the default login shell for new users (e.g.,
/bin/bash
,/bin/zsh
).Home directory location — Specify where home directories should be created (defaults to
/home
).Extra groups — Define additional groups that new users should be added to automatically.
Use of skeleton directory — Set the location of default files (like
.bashrc
,.profile
) that get copied into a new user’s home directory.
These defaults make it easier to maintain consistency across user accounts, especially on multi-user systems or when scripting user creation.
If you're managing several systems or setting up users frequently, taking a few minutes to customize adduser.conf
can save you a lot of time and repetitive typing.
Wrapping Up
In my experience as a Linux power user, adduser
is far superior at creating new users in Linux. I use it more frequently when I need to create users. As a result, I recommend that everyone use it.
So how about you? Which do you prefer, adduser
or useradd
?
That's all! Thank you for getting this far. I hope you find this guide useful.