The adduser
and useradd
commands work differently.
useradd user_name
Simply creates the user. It doesn't even ask you for a new password. It also does not create the home directory for this user. All these things you have to do manually after creating the user.
OR you can tell it when running the useradd
command. For example, the command useradd -d /home/username -m username
, includes creation of a home directory for this user.
Set the password after creating user, by passwd username
.
adduser
root@ubuntu-server:~# adduser username
Adding user `username' ...
Adding new group `username' (1006) ...
Adding new user `username' (1006) with group `username' ...
Creating home directory `/home/username' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for username
Enter the new value, or press ENTER for the default
Full Name []: User name
Room Number []: 405
Work Phone []: 555-412-5555
Home Phone []: 412-555-5555
Other []:
Is the information correct? [Y/n] y
The adduser
command does everything automatically for you as shown here.
The adduser
command is much more convenient for creating users. The reason useradd
is provided even when there is adduser
is that not all distributions come with adduser
.
adduser
is different fromuseradd
.-r
flag when removing a user to ensure that the home directory and mail spoolers have been removed