---
title: How to Create a Sudo User on a Linux Server
url: https://docs.vultr.com/how-to-create-a-sudo-user-on-a-linux-server
description: Learn how to create a sudo user on a Linux server with step-by-step instructions. Enhance your server security while maintaining administrative access.
publish_date: 2025-11-06T14:39:48.464000Z
last_updated: 2025-11-06T16:31:12.523594Z
author: Aashish Chaurasiya
header_image: https://docs.vultr.com/public/doc-assets/2361/8b52499f-ad45-4533-b7db-5310efc21445.png
---

> Index of every Vultr Docs page in markdown: https://docs.vultr.com/llms.txt

Creating a `sudo` user improves security by allowing you to perform administrative tasks without logging in as the root user. It helps reduce the risk of accidental system wide changes and improves auditing capabilities. By assigning `sudo` privileges to specific users, you can also achieve finer grained permission management and control who can perform administrative operations.

This article explains how to create a sudo user on multiple distributions, including Ubuntu, Debian, and FreeBSD.

## Prerequisites

Before you begin, you need to:

* Have access to a [Linux server](https://www.vultr.com/features/operating-systems/) as a root or non-root user with sudo privileges.

???+ note "Create a Sudo User on Ubuntu and Debian"

    Follow the steps below to create a new user and give them sudo privileges.

    1. Create a new user. Replace `john` with your desired username.

        ```console
        $ sudo adduser john
        ```

        When prompted, enter a **password** for the user and other additional information such as **full name** or **phone number**.

    1. Add the new user to the `sudo` group to grant `sudo` privileges.

        ```console
        $ sudo usermod -aG sudo john
        ```

    1. Switch to the newly created user account.

        ```console
        $ sudo su - john
        ```

    1. Run a `sudo` command to confirm that the user has `sudo` privileges.

        ```console
        $ sudo whoami
        ```

        When prompted, enter the user's password. If the command returns `root`, it confirms that the user can execute commands with sudo privileges. For advanced configurations, such as managing password prompts or restricting specific commands, refer to [this article](https://docs.vultr.com/how-to-create-a-sudo-user-in-linux#manage-password-prompts-for-a-sudo-user).

??? note "Create a Sudo User on AlmaLinux, Rocky Linux, and CentOS"

    Follow the steps below to create a new user and assign `sudo` privileges on AlmaLinux, Rocky Linux, or CentOS.

    1. Create a new user. Replace `john` with your preferred username.

        ```console
        $ sudo adduser john
        ```

    1. Set a password for the new user.

        ```console
        $ sudo passwd john
        ```

        When prompted, enter and confirm a secure password.

    1. Add the user to the `wheel` group to grant `sudo` privileges.

        ```console
        $ sudo usermod -aG wheel john
        ```

    1. Confirm that the `wheel` group is configured to allow `sudo` access.

        Open the sudoers file with `visudo`:

        ```console
        $ sudo visudo
        ```

        Ensure the following line is **uncommented**:

        ```ini
        %wheel ALL=(ALL:ALL) ALL
        ```

        This allows all users in the `wheel` group to run commands with `sudo`.

    1. Switch to the new user account.

        ```console
        $ sudo su - john
        ```

    1. Run a `sudo` command to test privileges.

        ```console
        $ sudo whoami
        ```

        Enter the user's password when prompted. If the output is `root`, the user has successfully been granted `sudo` privileges.

??? note "Create a Sudo User on FreeBSD"

    Follow the steps below to create a new user and assign `sudo` privileges on a FreeBSD system.

    1. Install the `sudo` package.

        ```console
        # pkg update && pkg install sudo
        ```

    1. View the installed version of `sudo`.

        ```console
        # sudo -V
        ```

    1. Create a new user account.

        ```console
        # adduser
        ```

        When prompted, enter the **username** and other details such as **UID**, **shell** and **password**.

    1. Add the newly created user to the `wheel` group.

        ```console
        # pw usermod john -G wheel
        ```

    1. Open the sudoers file using `visudo`.

        ```console
        # visudo
        ```

        Make sure the following line is uncommented to allow users of the `wheel` group to use `sudo`.

        ```ini
        %wheel ALL=(ALL:ALL) ALL
        ```

    1. Switch to the new user account.

        ```console
        # su - john
        ```

    1. Run a `sudo` command to verify access.

        ```console
        $ sudo whoami
        ```

        When prompted, enter the user's password. If the output is `root`, the user has `sudo` privileges.

## Conclusion

In this article, you learned how to create a `sudo` user in Debian-based and FreeBSD systems. You created a new user, assigned the appropriate group membership (`sudo` or `wheel`), and verified administrative access using `sudo`. These steps improved system security by limiting direct root usage and enabled controlled, auditable administrative privileges across different operating systems.
