Setup a Non-root User on a Linux Server (Ubuntu)

Tutorial Difficulty Level    

Having only one user, which is root, can be dangerous.  Running your own personal server allows you the freedom of doing whatever you wish, so let’s make use of this by adding a user with sudo access instead of direct root access.

We need to first connect to the server with root so that we have adequate permissions. Once connected, add another user account.

Replace <username> with the desired username.

That command will add the user to the list of users on the system, and create a corresponding group (if the group doesn’t exist).

Now we need to give this new user sudo access. We do this by editing the “sudoers”  file.

Even if you’re root, you will need to run the “sudo” part of the following command.

This will bring up a file with a bit of default info. What you need to look for is the following section:

Find where “root” appears in the list shown above, and add the following below it.

Substitute the appropriate variables.

We are almost finished. A few more minor steps.

Create the home folder for the new user.

Give the new user permissions in that folder.

Set a password for the new user.

Add the following to the /etc/passwd file.

Reboot the server for these changes to take effect.

Your new user account is now ready-to-go with sudo access! You may log into the server with this new account and use sudo when necessary.