useradd vs adduser differences


Today I understand some basic difference about the useradd and adduser command in linux with different distros.

Debian or Ubuntu:

In this distro, adduser is a perl script which uses useradd to perform a variety of tasks. Example is given below.

root@hostname:~# adduser test1

Adding user `test1′ …

Adding new group `test1′ (1003) …

Adding new user `test1′ (1002) with group `test1′ …

Creating home directory `/home/test1′ …

Copying files from `/etc/skel’ …

Enter new UNIX password:

Retype new UNIX password:

passwd: password updated successfully

Changing the user information for test1

Enter the new value, or press ENTER for the default

Full Name []: test1

Room Number []: 1

Work Phone []: 2

Home Phone []: 3

Other []: 4

Is the information correct? [Y/n] y

root@hostname:~#

If you use useradd then it creates the user by default and returns. Example is given below.

root@hostname:~# useradd test

root@hostname:~#

You can see the difference by

root@hostname:~# cat /etc/passwd |grep test

test:x:1004:1004::/home/test:/bin/sh

test1:x:1002:1003:test1,1,2,3,4:/home/test1:/bin/bash

root@hostname:~#

Fedora, RedHat or CentOS:

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

[root@hostname1 ~]# ls -l /usr/sbin/adduser

lrwxrwxrwx. 1 root root 7 Dec 16  2011 /usr/sbin/adduser -> useradd

[root@hostname1 ~]#

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: