Linux administrators have few options when it comes to adding a new user to the system, from filling up forms in distribution / desktop environment specific nice GUIs, to running through the command line with options and switches. For the geeky administratorss, there are always configuration files that can manually be edited just for this purpose.
The 2 most common programs used to add a user are, adduser and useradd. They are both quite similar (heck, they do the same thing anyway, which is to add user of course), but are a bit different in their interactivity level.
You can new user in
Linux from the command line using
useradd and you can also add new user using
GUI provided by
adduser is quite interactive, the only required parameter to be supplied to the program is the user name to be added while running the program. The rest of the process is a matter of filling up questionaires provided by the program, and a user is then created. The following example shows how to add the user noob to the system.
$ sudo adduser noob Adding user `noob' ... Adding new group `noob' (1003) ... Adding new user `noob' (1003) with group `noob' ... Creating home directory `/home/noob' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for noob Enter the new value, or press ENTER for the default Full Name : newbie Room Number : Work Phone : Home Phone : Other : Is the information correct? [y/N] y
The only mandatory field to be filled up is just the password, and surely to also key in y at the end to confirm your action.
useradd is normally the preferred choice for non-interactive uses, and at minimum it also accepts only the username as parameter. The following is and example on how to add the user noob using useradd;
# useradd noob
and that’s just it. It is however pretty useless as it lack many things, and the following example should make it more useful;
# useradd -g users -G admin -s /bin/bash -d /home/noob -m noob
The command above will add the user noob with the primary group users, and also including the user to the group admin, setting the default shell to /bin/bash, define the home directory to be at /home/noob, and to create the home directory. Password is not yet set at this point, and the following step sets up the password;
# passwd noob Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
For the geeks and those with brave heart, you are free to edit the following files to change user informations, and even to add a user to the system.