---
title: How to create a sudo user on your server
description: "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…"
url: "https://truehost.com/support/knowledge-base/how-to-create-a-sudo-user-on-your-server/"
updated: "2024-10-08"
category: Cloud servers in Kenya
---

# 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**

- Root SSH access to the server.

##### **Step 1: Log in to Your Server** -

- Log in to the server via SSH using **[these steps](https://truehost.com/support/knowledge-base/how-to-access-a-server-via-ssh-terminal/)**

##### **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

![](https://truehost.com/support/wp-content/uploads/2024/10/image-158.png)

- 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.

![](https://truehost.com/support/wp-content/uploads/2024/10/image-159.png)

##### **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
```

![](https://truehost.com/support/wp-content/uploads/2024/10/image-160-1024x700.png)

##### **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

## **Important Links**

1. **[How to disable root ssh completely](https://truehost.com/support/knowledge-base/how-to-disable-root-ssh-completely/)**
2. **[How to disable root ssh with password but enable via ssh keys](https://truehost.com/support/knowledge-base/how-to-disable-root-ssh-with-password-but-enable-via-ssh-keys/)**
3. **[How to change SSH port to a custom port](https://truehost.com/support/knowledge-base/how-to-change-ssh-port-to-a-custom-port/)**
4. **[How to prevent password request when running sudo commands](https://truehost.com/support/knowledge-base/how-to-prevent-password-request-when-running-sudo-commands/)**
