The differences between useradd and adduser commands

Recently, I wrote an article about Managing user accounts on Linux based systems. And I got a suggestion on the use of command adduser in place of useradd. So, I did a little research about the main differences between these two commands and came up with this article which I believe will be useful to a lot of linuxers.

I got the content by searching web so I might be wrong about some points. Don't hesitate to correct me there. Starting from the beginning, useradd can be considered as the native command of any UNIX or Linux based systems. They are compiled into the system. But recently most of the UNIX or Linux based systems have started replacing this command with adduser. Although adduser in some distros is either just a wrapper to provide some sequential functionalities with all the work still being done underneath by useradd or an just a simple alias to useradd.

Adduser differs in different distros.

Debian or Ubuntu

In these systems, adduser is a perl script which uses useradd to perform a variety of tasks. e.g this is the output when I tried to create a user "chia" using adduser in Ubuntu.

user:~$ sudo adduser chia
[sudo] password for user:
Adding user `chia' ...
Adding new group `chia' (1001) ...
Adding new user `chia' (1001) with group `chia' ...
Creating home directory `/home/chia' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for chia
Enter the new value, or press ENTER for the default
    Full Name []: Tushar Mahajan
    Room Number []: 357
    Work Phone []:
    Home Phone []:
    Other []:
Is the information correct? [Y/n]

Similar is the case with addgroup, an alternative to groupadd. According to the manpage of "adduser"

adduser and addgroup 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.

In case you noticed, I used the term sequential functionalities. In adduser, these seq. functionalities are creating the user, adding it to a group, setting the UID and GID, creating a home directory etc.

Fedora, RedHat or CentOS

In these RedHat based systems, adduser is present as a symbolic link to the actual useradd command.

[root@chia ~]# ls -l /usr/sbin/adduser
lrwxrwxrwx 1 root root 7 2010-01-28 15:15 /usr/sbin/adduser -> useradd

Others

It fairly differs in other systems. I was reading the FAQ page of Gentoo Linux where they have used useradd to create a normal user. And in Solaris useradd seems to be a history.

At the end, all I can say for sure is that different operating systems have adduser as an alternative to useradd whose functionality is distro-specific. It can be just a simple alias to useradd or a script with additional options.

There is nothing wrong with using useradd to create users and set different options for them. But if you are using a Debian based distro then it is advised to go for adduser/addgroup to create a normal user/group with basic options. If you want advanced settings then go for useradd/groupadd.

2 Comments

Anon Linuxer (not verified)
July 7th, 2010 07:50 pm
Great post. Thanks
Anon Linuxer (not verified)
September 2nd, 2010 08:47 am
Yes, I like your post,it's very good for us.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <p> <br>
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.
  • Search Engines will index and follow ONLY links to allowed domains.

More information about formatting options

Mollom CAPTCHA (play audio CAPTCHA)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.