DEV Community

Cover image for useradd vs adduser: Which command to use?

useradd vs adduser: Which command to use?

Linux is amazing! Let me tell you what made me say so.

There are multiple ways to perform a function in Linux. Let's say you simply want to print "Hello World" to the screen. To do so, some beginners might create a new file, write "Hello world" to it and then use the cat command to print the contents of the file. Some experienced users may use the echo command to print the same to the screen. Both of them are correct as the job is done perfectly but the only difference is that using the echo command, we can accomplish the job quickly.

In this blog, we are going to discuss about one such function of creating a new user using two commands adduser and useradd. We'll also talk about which command you must use and when.

Let's dive right into it.

adduser command

The adduser command creates a new user on a linux system. Apart from this it does the following things:

  • Creates a new group.
  • Creates the home directory for new user under /home.
  • Asks for the password.
  • Asks for additional information such as Full Name, Room number, Work phone, Home phone and other information.

Note that you need superuser permissions to execute the command.

adduser command

useradd command

The useradd command does the same thing as adduser command i.e creating a new user but with few differences.

  • It does not create a home directory for the new user by default.
  • It does not ask for password.
  • It does not ask for any additional information.

Note that you need superuser permissions to execute the command.


Although it does not ask for any additional information by default, you can provide them that information using the flags given below:

-c, --command : GECOS field for the new account.
-D, --defaults : Create new user with default set values.
-m, --create-home : Create user's home directory
-p, --password : Set Password for the account.
-e, --expire : Set the expiry date for the user.

You can view additional flags by using the command:

useradd --help
Enter fullscreen mode Exit fullscreen mode

Which one should I use and when?

Well, in most of the cases you must use adduser command. It's easy to set up password, create home directory etc., using this command.

But that doesn't mean useradd command is useless. If you temporarily want to create a user without providing much details for the account, you can use the useradd command. Generally it's used while executing commands in automated way in scripts.

That's all for the blog. Comment down below your go-to command for creating a user.

Thank you for reading!

Top comments (5)

apapsch profile image
Aljosha Papsch

adduser is a Debian thing, nice for its interactive mode. useradd on the other hand is part of the shadow package and can be expected to be found on many different distributions.

raibtoffoletto profile image
Raí B. Toffoletto

I think adduser is just a python wrapper if I remember.
I personally always go with useradd even in deb based distros.

aaravrrrrrr profile image
Aarav Reddy

Really like this

sneh27 profile image
Sneh Chauhan

Thanks aarav!

ivis1 profile image
Ivan Isaac

Thank you.