Beta 42

Research and Development

Menu

Create New User

Generally, there are two linux commands to create users - useradd and adduser.

Note that useradd is built-in Linux command that can be found on any Linux system, whereas adduser is only for Debian and the derivatives.

Furthermore, useradd is a native binary compiled with the system, and adduser is a perl script which uses useradd binary in the back-end. Note that adduser provides an option –disabled-password while useradd does not. However, useradd can achieve the same using a different option or combination of options (like –inactive).

Finally, adduser is more user friendly and interactive than its back-end useradd. Otherwise, there is no difference in features provided.

Creating a user account using useradd command

The syntax is:

sudo useradd -s /path/to/shell -d /home/{dirname} -m -G {secondary-group} {username}
sudo passwd {username}

Example:

sudo useradd -s /bin/bash -d /home/zerocool/ -m -G sudo zerocool
sudo passwd zerocool

Where:

-s /bin/bash - Set /bin/bash as login shell of the new account
-d /home/zerocool/ - Set home directory of the new account
-m – Create the user’s home directory
-G sudo - Make sure the new user is a sudoer

List Available Shells

Use echo $SHELL to see your current shell.

All shells available on the system could be listed using:

cat /etc/shells