How to create sudo user on Ubuntu 18.04 Bionic Beaver Linux

Objective

This article will explain how to create a sudo user on Ubuntu 18.04 Linux. First, we will look at creation of new sudo user using command line and later we will create a sudo user from Ubuntu’s graphical interface.

The sudo user can execute any command with administrative privileges, hence execute commands as root.

Operating System and Software Versions

  • Operating System: – Ubuntu 18.04 Bionic Beaver
  • Software: – Sudo version 1.8.21p2 or higher

Requirements

Privileged access to your Ubuntu System as root or via sudo command is required.

Conventions

  • # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ – requires given linux commands to be executed as a regular non-privileged user

Other Versions of this Tutorial

Ubuntu 20.04 (Focal Fossa)

Create a sudo user using command line

To be able to create a sudo user we first need to create a regular user. To do so we can use adduser command. Visit How to Add user on Ubuntu 18.04 for more information on how to create new users.

Let’s start by creating a new user called lubos. Open up terminal and enter:

$ sudo adduser lubos

Next, we we need to add the new user to an existing sudo group:

$ sudo usermod -aG sudo lubos

All done. We have just created a new sudo user lubos. At this stage we are going to test new sudo privileges. Use su command to login as the new user you have just created:

$ su lubos
Password: 
To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.

Using a sudo command we are now able to run any command with root privileges by prefixing the actual command with sudo. We are also able to gain root prompt:

 
$ sudo -i
[sudo] password for lubos: 
# 

Note the # character. This means we are now logged in as root. To confirm run:

# whoami 
root

The below video will summarize the entire sudo user creation process:



Create a sudo user using GUI

Using your graphical interface simplify sudo user creation on Ubuntu 18.04 desktop. We few click we are able to create user and at the same time assign the user sudo administrative privileges.

Consider a following example on how to create a sudo user on Ubuntu 18.04 Desktop:

create a new user - window

To create a new user on Ubuntu GNOME Desktop, first open SETTINGS window. Next navigate to About->Users menu. Press the top right Unlock button to get into administrative mode.

get administrative privileges

Enter your administrative password.

Create a new user on Ubuntu desktop

Hit Add user... button in order to create a new user.



Add user to sudo

Select Administrator account type to automatically add user to sudo group. Fill in all required information.

New sudo user is ready to use.

All done. New sudo user has been created.