How to create a sudo user on your server

Creating a sudo user on your server allows you to manage administrative tasks securely without needing to use the root account directly. A sudo user has permission to execute commands with root privileges, which adds a layer of security to your system. Requirements Step 1: Log in to Your Server โ€“ St

Last updated 30 Nov 2026Also in: Dedicated Servers

Creating a sudo user on your server allows you to manage administrative tasks securely without needing to use the root account directly. A sudo user has permission to execute commands with root privileges, which adds a layer of security to your system.

Requirements

  • Root SSH access to the server.
Step 1: Log in to Your Server โ€“
Step 2: Create a New User
  • Once logged in, create a new user by running the following command. Replace newuser with the desired username. This command creates a new user and its home directory.
adduser newuser
  • Replace newuser with the desired username. This command creates a new user and its home directory. In the image below, we are creating a user called tke
  • You may be asked to input user details as in the image below. Youn can put them or just hit Enter key to proceed

  • Now, set a password for the newly created user using the command below, again replacing new user with the name of your actual user that you just created
passwd newuser
  • You will be prompted to enter and confirm a password.
Step 3: Add the User to the Sudo Group
  • To grant the new user sudo privileges, add the user to the sudo or wheel group based on your OS destribution.
  • On most Linux distributions, users in this groups are allowed to use sudo to run commands with root privileges.
  • On Ubuntu, Linux Mint, Debian and other Debian-based OSes, use the command below to add your user to sudo group.
usermod -aG sudo newuser
  • For CentOS, Almalinux or RedHat systems, use the wheel group instead:
usermod -aG wheel newuser
  • The -aG option adds the user to the specified group (sudo in this case) without removing it from other groups.

Step 4: Verify Sudo Access
  • To verify that the new user has sudo privileges, log out from the root account:
exit
  • Log in again using the newly created user:
ssh newuser@your_server_ip
  • Test sudo privileges by running a simple command such as the one below
  • When you runt he command, youโ€™ll be prompted for the new userโ€™s password.
  • If everything is set up correctly, the command will return root, indicating that the user has sudo privileges. See the highlights in the image below;
sudo whoami

Step 5: Optional โ€“ Customize Sudo Privileges
  • You can do other optional tweaks on the server as you desire. These are optional and you should only dot hem if you with. See the important links section below
  1. How to disable root ssh completely
  2. How to disable root ssh with password but enable via ssh keys
  3. How to change SSH port to a custom port
  4. How to prevent password request when running sudo commands
cloud servers in kenyaservers