2

The differences between useradd and adduser commands

view story
linux-howto

http://linuxers.org – 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. (General)