Home Linux server Useradd vs. adduser in Linux. Is there a difference?

Useradd vs. adduser in Linux. Is there a difference?

by The Linux Digest Guy
useradd vs adduser

If you search for information online about how to add a user in Linux, you will find some conflicting information. Some will tell you to use the useradd command, others will tell you to use adduser. Some will tell you that both commands are equal and some will say they are not the same.

Is there a difference between useradd and adduser? The short answer is that it depends on your distribution. Useradd is a native binary that is always included with a Linux system. Adduser is not always the same thing.

So, which should you use? Both perform basicly the same task, so you can use either one. Let’s see what the difference really is.

Useradd

The useradd command is a standard utility, that comes with most Linux distributions. It behaves the same way in most setups. Default values depend on the settings that the system has in /etc/login.defs and /etc/default/useradd. The default values may be whether a home directory is created for the user, what primary group is used etc.

There may be some minor differences in behavior in some distributions. But in most cases, the binary will come from the password shadow package.

Adduser in Debian based distributions

In Debian based distributions, like Debian, Ubuntu, Linux Mint, Kali, etc., the adduser utility is a Perl script. This script also calls useradd to perform the actual actions. So basically, the script does the same thing as useradd.

The difference is that adduser is meant to be more user friendly. It will print more verbose information about what it is doing. Such as what uid and gid are allocated, where the home directory will be located, etc.

It is also more interactive and will ask for information that is not provided with command line options.

Adduser in Red Hat-based distributions

Adduser in Red hat based distributions, like RHEL, CentOS, Fedora, etc., is effectively the same as useradd. In most cases, it is just a symbolic link that points to the useradd binary.

In these distributions it really does not matter which one you use.

Adduser in openSUSE based distributions

From what I gather, adduser does not exist in openSUSE based distributions. So if you are using one of these distros, you will always user useradd.

Conclusion

Since useradd is available in most, if not all, distributions. It is problably best for most administrators to make sure that they know their way around useradd.

However, if you mainly use Debian based distributions, adduser offers more flexibility and is more user friendly than the original binary. So it definately doesn’t hurt to use that version. Just remember: when you are thrust into a situation where you need to manage a different flavor of Linux, you might have to read some man pages.

If you know of other differences between the two, that I didn’t list. Please leave me a comment so I can include that in the article.

2

Related Posts

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Privacy & Cookies Policy