How to create users on a Linux server

Generally speaking, you do not normally need to add new website users from the command line on a web server with a control panel. Most control panels will automatically setup users and groups when new websites are created. There are, however, times when you might want to create users and groups manually.

For example, if you need to install certain software, such as a complex Perl application, it may require its own user and user group. You may also need to assign assign privileges to that user. Another scenario is that you are using your dedicated server for something other than web hosting and do not have a web-based control panel. It might be a gaming server or chat server, and adding control panels and other systems would only take up system resources that you need elsewhere.

To add a user, follow these steps:

1. Login to your server via SSH
2. Become root:
3. As an example, let’s say you want to make a user called “gamerdude” with a group by the same name (default setting). Type this from the command line:

adduser gamerdude

4. When it asks for a password, enter the user’s password
5. It will ask for other information like “phone number.” This is optional.
6. If all of the information is correct, press “y” yes.

Sample output:
# adduser testman3
Adding user `testman3' ...
Adding new group `testman3' (1004) ...
Adding new user `testman3' (1004) with group `testman3' ...
Creating home directory `/home/testman3' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for testman3
Enter the new value, or press ENTER for the default
Full Name []: Test Man
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y

To assign file ownership to the new user, use the following command:

chown gamerdude:gamerdude /var/www/files/filename

To assign ownership of an entire directory, enter:

chown -R gamerdude:gamerdude /var/www/files

Later this week, I will explain how to create a group without creating a user and how to assign multiple users to the group.