The Linux Create User Function

The Linux Create User Function
Page content

Many Linux distributions (distros) are designed as multi-user systems offering solid security and management for the corporate environment, while others such as Puppy Linux were developed with the single user in mind. One of the many tasks for which a Linux system administrator is responsible is the addition of new accounts. The Linux create user function is fairly simple to learn and can be safely practiced with fictitious names.

The User Add or the Add User Function?

The Linux create user operation can be carried out with the command useradd, however, on some Unix-like systems, you’ll find that adduser works. The adduser command is a symbolic link to useradd. I can use either on my Fedora 8 system; you may find that either works on your distro as well. User names can be alphanumeric as long as they don’t begin with characters reserved for shell use. The norm, however, is to use the first name and last initial which tends to make things easier for administrators. Remember that the system knows users by their user id, not by their user names or real names. Each account you add will also need a good password. Administrators can have the initial password be something simple that the person then changes to one he can remember. Generally, strong passwords are alphanumeric and case sensitive.

The Linux create user function will establish every new account, unless otherwise specified, with a set of defaults that can be modified. You will need to be root or a user with superuser privileges to set up accounts and to alter defaults. Simply go into a terminal, which may also be called a console, become root if necessary, and take a look at the defaults by issuing the command useradd -D. The D is the option that allows you to see the defaults. You should see something like the following:







The default group for new accounts is 100, the user will be set up with a home directory, neither his account nor his password is set to expire, and he’ll use the bash shell and the defaults for the shell are located at /etc/skel. Defaults might be different on your distro.

Practice Creating an Account

Using the Linux create user function isn’t difficult, especially when using defaults. Again, you may notice some slight differences on different systems. Setting up accounts on Puppy Linux was different from setting them up on Fedora. Actually, there’s really no need to establish different users on a system like Puppy; I just practiced out of curiosity because it was designed for a single user who works in graphic mode. Therefore, I’ll concentrate on the experience with Fedora which is much more likely to be encountered in the real world.

Once you’re at the command line, simply type useradd plus the name of the user as in useradd JohnD. Next type passwd JohnD to assign him a password. If you enter a simple word that could easily be discovered, most systems will let you know by printing a warning message to the screen. However, it will let you continue. You’ll then be prompted to enter the password and then to verify it by typing it again. It’s very important to give the user a password so he’ll be able to log in. The useradd function has many options with which it can be used. You can resort to calling on these options to accomplish what you need such as bypassing the defaults. We know that the default shell for JohnD is bash, but what if we wanted to change that to the Z shell (zsh)? We can do that by using options, but make sure that shell truly exists. You can usually count on the presence of the bash shell. We could have typed useradd JohnD -s /bin/zsh.

The Linux Create User Function in Graphic Mode

Remember that some administrative tasks are best handled on the command line as GUI’s sometimes only allow work with a subset of operations. The addition of accounts in graphic mode under Fedora (version 8) involves clicking on System, highlighting Administration, and choosing Users & Groups. You can see the user Samuela that I’ve created if you click on the screen shot below. The steps to actually use the Linux create user function are pretty self-explanatory. If you choose to practice this operation, but don’t know how to properly delete the fictitious users on a command line, just resort to the GUI for their removal.