Grid Guides

Explore How System On Grid Can Work For You

Grid Guide Topics

How To Create a Sudo User on Ubuntu [Quick Start]

Table Of Contents


    ## Table of Contents

    – [Introduction](#introduction
    – [Prerequisites](#prerequisites
    – [Steps to create a New Sudo User](#steps-to-create-a-new-sudo-user
    – [Conclusion](#conclusion

    ## Introduction

    The Sudo command grants administrator privileges. Generally, It is only available to the root user to the Normal users.

    In this guide, we are showing the easiest way to create a new user with sudo privileges on Ubuntu.

    ## Prerequisites

    Running Server

    ## Steps to create a New Sudo User

    ## Step 1

    To Log in to your server as the root user enter the below command.

    “`
    local$ ssh root@server_ip_address
    “`

    ## Step 2

    If you want to add a new user to your system then use the adduser command. You have to put the username of the user in place of username as shown below.

    “`
    # adduser username
    “`

    You have to set the password at the prompt and confirm it. Note that a strong password is highly recommended as shown below.

    ![unixpassword](https://grid.media/assets/images/unix-password-02132019.png

    Follow the prompts if you want to set the new user’s information. And you have to accept the defaults to leave all of this information.

    ![changeuserinformation](https://grid.media/assets/images/change-user-information-for-ubuntu-test-user-02132019.png

    ## Step 3

    To add the user to the sudo group use the below command.

    “`
    $ usermod -aG sudo username
    “`

    In Ubuntu, By default, the members of the sudo group have sudo privileges.

    ## Step 4

    If you want to test sudo access to the new user account then test it using below command.

    “`
    # su – username
    “`

    Now you are a new user, you can test that you can use sudo by adding sudo to the command like this.

    “`
    username$ sudo command_to_run
    “`

    For example, If you want to list the contents of the /root directory, which is usually accessible to the root user.

    “`
    username$ sudo ls -la /root
    “`

    ![contentsaccesible](https://grid.media/assets/images/contents-accessible-for-the-root-user-02132019.png

    If you use sudo in a session for the first time, then you will be prompted to a password of the user account. Enter the password to proceed further.

    ![passwordforubuntutest](https://grid.media/assets/images/password-for-ubuntutest-02132019.png

    If the user entered the correct password and he is an inexact group then that user will have sudo with root privileges.

    ## Conclusion

    Now the user has sudo privileges.