Note: You must have root access to add a user. If you are logged in as a regular user and know the root password, you can type the command su. This will prompt you for a password. Enter the root password correctly and you will have root priviledges until you type exit. Typing exit will take you back to regular user mode.
After changing to root, the command adduser can be used to add users to your machine. In Red Hat Linux, the adduser command is located in the /usr/sbin directory. To invoke the command you might have to type /usr/sbin/adduser (the full path) if /usr/sbin is not in your path.
To add a user with the default values for the user's home directory and shell type, simply type the following command:
adduser username where username is the name of the user you wish to add.
In Red Hat Linux, the default home directory is /home/username, and the default shell is the bash shell. The adduser command has many other options to choose from. Below is a list of all switches for the adduser command.
adduser [-u uid [-o]] [-g group] [-G group,...]
[-d home] [-s shell] [-c comment] [-m [-k template]]
[-f inactive] [-e expire mm/dd/yy] [-p passwd] [-n] [-r] name
adduser -D [-g group] [-b base] [-s shell] [-f inactive] [-e expire mm/dd/yy]
The -D switch is used to either view the current default values for adding a user or to change the default values for adding a user. Typing adduser -D will display the default settings.
To use the switches, type adduser -switch switchvalue. For instance, to add the user bob with the home directory of /home/users/bob, type the following command:
adduser bob -d /home/users/bob.
The last step to adding a user is to set the user's password. To do so, type the following command: passwd username (where username is the username of the new user)
This will prompt you to enter a password. Enter the password and press enter. You will be asked to confirm the password. Type the password in again and press enter. As long as you typed the same password in both times, you have finished adding a new user. If you did not enter the same password both times, you will be asked to reenter the password again until you confirm it correctly.