How to Install and Manage Sudo

Sudo is a linux command which can be used to grant root-level access to authorized users without requiring these users to login as the root user. This is useful for securing a server by disabling root access and instead granting sudo access to select users.

In this article, we’ll outline how to install sudo and add users to the sudo group.

How to Install Sudo

If sudo is not yet installed on your server, follow these commands in order to install sudo on Debian, CentOS, or FreeBSD:


apt-get install sudo -y


yum install sudo -y

How to Add Users to the Sudo Group

Debian / CentOS / FreeBSD

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

adduser mynewusername

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


usermod -aG sudo mynewusername


usermod -aG sudo mynewusername

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 “hello world”

You will be prompted to enter the password of the user, and the screen will display hello world when executed successfully:

user@debian:/root$ sudo echo “hello world”hello world

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

user@debian:/root$ sudo echo “hello world”user is not in the sudoers file. This incident will be reported.

Next Steps

Check out our other Knowledge Base articles including the Top 5 Ways to Secure Your Linux Server.


Bare Metal Dedicated Servers

A single tenant, physical server allowing you full access to its resources.

Browse servers

Professional Hybrid Servers

Virtualized server platform hosted on enterprise-grade physical servers.

Browse servers

Scalable Cloud Servers

High-performance and highly-available infrastructure.

Browse servers

Managed Colocation

Our next-generation data center facilities.

Browse servers

Your email address will not be published.

There are no comments yet, why not be the first?