• About Us
  • Contact us
  • Disclaimer
  • Privacy Policy

Linuxtor

Linux Tips, Tricks and DevOps Tutorials

  • Home
  • Ubuntu
  • CentOS
  • Debian
  • Commands
  • DevOps
  • Series
You are here: Home / Ubuntu / How To Create a Sudo User in Ubuntu Linux

How To Create a Sudo User in Ubuntu Linux

February 9, 2022 by Asmita Leave a Comment

How To Create a Sudo User in Ubuntu Linux

The sudo command on the ubuntu system is useful to get sudo privileges on the machine to perform administrative tasks. It allows running user programs with the security privileges of the root user.

In this article, we will discuss how to create a sudo user on Ubuntu machines. This type of sudo accounts can be used to execute administrative commands without login to the Ubuntu server as the root user.

Table of Contents

  • 1 Steps to create a sudo user
      • 1.0.1 1. Login to your Ubuntu server
      • 1.0.2 2. Create a new user account
      • 1.0.3 3. Add new user to the sudo group
  • 2 How to use sudo command
    • 2.1 More on how to create a sudo user on ubuntu

Steps to create a sudo user

Follow the simple steps mentioned below and create a new user account on Ubuntu. Additionally, you will have to provide sudo access as well. If you have an existing user and want to configure sudo for an existing user, then skip to step 3.

1. Login to your Ubuntu server

First of all, login to the ubuntu server as a root user. Enter the command below in the terminal.

ssh [email protected]_ip_address

In the above command, server_ip_address is the ipv4 address of your server. For example, If the IP address is 127.0.0.1 then write like this.

ssh [email protected]

2. Create a new user account

To create a new user account on Ubuntu Linux, you will have to use adduser command. Enter the following command on the terminal.

adduser linuxtor

In the above command, replace linuxtor with the desired username you want to use.

After writing the command, hit the Enter button. You will be prompted to enter and reconfirm the new password for linuxtor account. Make sure to enter a strong password for your account.

[Output]
Adding user `linuxtor' ...
Adding new group `linuxtor' (1001) ...
Adding new user `linuxtor' (1001) with group `linuxtor' ...
Creating home directory `/home/linuxtor' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully

After setting up the password for linuxtor user account. The command will automatically create a home directory for linuxtor user. It will also add some configuration files in the ubuntu home directory. It will ask you to set such configurations. If you want to leave the default settings, just press ENTER to proceed ahead with default values.

[Output]
Changing the user information for linuxtor
Enter the new value, or press ENTER for the default
    Full Name [ ]:
    Room Number [ ]:
    Work Phone [ ]:
    Home Phone [ ]:
    Other [ ]:
Is the information correct? [Y/n]

3. Add new user to the sudo group

To provide administrative access to any user on ubuntu systems. you will have to grant access to the user by adding to the sudo group. To add a new user to sudo group you will have to use the usermod command indicated as below.

usermod -aG sudo linuxtor

In above command, linuxtor is a username, replace it with your username.

Now, we’re done! Let’s check whether our configurations are correct or not. To do that, we will switch to the newly created user using su command.

su - linuxtor

It will ask for the password of linuxtor user. Type the password and press ENTER.

[Output]
[sudo] password for linuxtor:

Now, enter whoami command with sudo to know the status of the current user you are logged in.

sudo whoami

If the given user have sudo access, then it will return output as below.

[Output]
root

How to use sudo command

To use sudo command, type sudo before any command you enter in Linux terminal.

sudo ls -a

More on how to create a sudo user on ubuntu

I am pretty confident that you have learned how to create a user with sudo permissions. Next, log in to your Ubuntu server with your created user account (In my case I will use linuxtor username) using sudo command. There are many more sudoers tweaks for ubuntu that you should know. We will discuss that in the next guide. Stay tuned.

Filed Under: Ubuntu, Commands Tagged With: sudo user in ubuntu, terminal

Leave a Reply Cancel reply

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

Recent Linux Guides

  • Explain pkill command in Linux
  • Linux File Command, Explain with Syntax and Examples
  • Explain rm command in Linux with Examples
  • What is the /etc/shadow file in Linux
  • How to List Installed Packages on CentOS
  • How To Create a Sudo User in Ubuntu Linux

Read More On

  • CentOS
  • Commands
  • Ubuntu

What is Linuxtor?

Linuxtor.com is your education source to learn more about Linux, Shopify, DevOps and MEAN/MERN Stack development. We are a team of enthuasist pertaining to provide maximum possible guidance on or related to the Linux platform.

Explore about us

  • About Us
  • Contact us
  • Disclaimer
  • Privacy Policy

Copyright © 2022 All Rights Reserved Log in