User Account Creation by Text Mode in Linux

User account creation is one of the rare aspects of Linux administration where using text (command line) mode really isn’t any more challenging than using the usual graphical user interface tool. It goes without saying that it is an approachable step for a Linux newbie, and can go a long way in getting an idea about how to proceed in a command line environment.

The most obvious way to go about creating a user account is to use the useradd utility. Adduser is an alternative, which works exactly the same way as useradd (though it may or may not be present in all systems). For all practical purposes, they can be considered to be one and the same.

These utilities make account creation highly convenient and easy. The useradd command works as a function on a bigger and more complex scale. It accepts a number of options as arguments. In each case, an option is essentially a piece of information about the user whose account is being created. For instance, if you want to create a new user account for a user whose name is John, you need to know the UID (Unique ID) you want to assign him, what his default shell would be, what his home directory would be, and finally, the password he’d want for his account. Let’s say that this user is going to have a UID number of 500; /bin/bash is to be his default shell; /home/harry is to be his home directory, and his password is 12345 initially. The command to do all this would be as follows:

useradd -u 500 -s /bin/bash -d /home/john -p 12345 john

The ‘-u’, ‘-s’, etc. in the command above are options to modify the behaviour of the utility. Below are few of the most utilized options:

‘-u’ refers to a numeric user ID;

‘-g’ refers to a numeric default group ID;

‘-G’ indicates that the user (John) may belong to more than one group;

‘-d’ refers to the home directory;

‘-s’ is the default shell;

‘-c’ is used to add a comment (e.g. additional information that can be used to identify the user);

‘-e’ is used to set an expiry date to a particular account, so as to make it stop working beyond a particular point of time.

Some of the ‘options’ (information pieces about the user) are not compulsory. E.g., the shell, home directory, and numeric ID are given default, sequentially allotted values if you choose not to explicitly specify them. As a general rule of thumb, you ought to specify a numeric ID only if you have an exact reason to do so. For instance, if you are shifting a user’s account from another computer, you might need it to have the same ID number on the new machine. In more generalized cases, however, you can let the machine assign numeric IDs.

A major advantage of getting used to the text mode for user account creation is that the text mode is almost exactly the same in all Linux distributions. The same doesn’t hold for graphical modes for account creation, as there tends to be a wide disparity between the interface offerings. All in all, despite the intimidation that a Linux newcomer might feel with command lines and text-only modes, user account creation is among the easiest command-based actions possible in Linux.

Leave a Reply