Accessing your VPS server directly with a root user is considered to be an unsecure method.The preferred method of working with your server is setting up an unpriveleged user + setting up sudo for it.Sudo means “substitute user and do”, so basically it allows your user to execute a command from another user. By default sudo is running commands from root user, however you may use it to run command from another unpriveleged user as well.

Steps to Create a New Sudo User

  1. Log in to your server as the root user.
  2. Use the adduser command to add a new user to your system.

    Be sure to replace username with the user that you want to create.

    adduser username


  3. Use the passwd command to update the new user’s password.
    passwd username                                                                  <span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>


  4. Use the usermod command to add the user to the wheel group.
    usermod -aG wheel username


Test sudo access on new user account

Use the su command to switch to the new user account.

su - username

Now you can list the contents of the /root directory, which is normally only accessible to the root user.

sudo ls -la /root

Default configuration file for sudo is



Was this article helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *