Skip to main content

1. Create Non-Root User with sudo permissions

If you entered a user at the start of the ubuntu server install, then you do not need to do this

Why do we even bother with a non-root user?

By utilizing a non-root user for performing command-line tasks, you decrease the chance of a major mishap from entering the wrong command from happening

Whilst you can make the mistakes with sudo, you will often think twice before issuing a command as you need to enter your password.

Creating a non-root user:

useradd -G sudo -m placeholder-username -s /bin/bash

Breakdown of command:

  • useradd is the command for creating a new user
  • -G is tag for group, you are creating user to be put in the sudo group
  • -m is for the username
  • -s indicates the default shell, in this case it is /bin/bash

Next, you need to create a password for your user:

passwd placeholder-username

Enter your password, and reenter your password to confirm. This is now your sudo password. REMEMBER IT!

And That's it! You've successfully created a non-root user!