Close this search box.

How to Install and Manage Sudo

Table of Contents

In this tutorial, we will show you How to Install and Manage Sudo on Debian and CentOS Servers


What is sudo And why would you use it?

The sudo command enables users to execute programs with the privileges of another user, typically the superuser. It originally stood for “superuser do” because older versions of sudo were designed to run instructions the most efficiently with the help of the superuser. Any Linux command can be run as the superuser with the sudo command. Say, for instance, you want sudo to have the right of entry to regulate a device document. you can exchange your user to the superuser in a shell using the su command.

How to Install and Manage Sudo?

Most Linux distributions come with the sudo package pre-installed.

To check whether the sudo package is installed on your system, open up your console, type “sudo” and press Enter. If you have sudo installed the system, will display a short help message. Otherwise, you will see something like sudo command not found.

Install Sudo on Debian 

apt-get install sudo -y
Install Sudo on CentOS
yum install sudo -y


How to Add Users to the Sudo Group


By default, on most Linux distributions granting sudo access is as simple as adding the user to the sudo group. Members of this group will be able to run any command as root. The name of the group may differ from distribution to distribution.

Debian / CentOS

Begin by adding the user account to the server if it does not already exist:

adduser newusername

Then you can add the user to the sudo or wheel group:


usermod -aG sudo newusername


usermod -aG wheel newusername

Testing Sudo Access


You have now installed sudo and added the user to the sudo group. You can test sudo access by switching into the new user using the su command executing:

sudo echo "hi there"

You will be prompted to enter the password of the user, and the screen will display ‘hi there’ when executed successfully:

user@debian:/root$ sudo echo "hi there"

hi there

If the user has not been added to sudo properly, it will display:

user@debian:/root$ sudo echo "hi there"

User is not in the sudoers file. This incident will be reported

Using the sudo command and creating and managing new users with sudo privileges has been successfully completed.


That’s it

Get the most out of learning with

Make a Comment
Share on
VPSie Cloud service

Fast and Secure Cloud VPS Service

For a month

The First 1 orders gets free discount today! Try Sign up on VPSie to get a chance to get the discount.