How To Install sudo on CentOS 7

In this tutorial we learn how to install sudo on CentOS 7. sudo is Allows restricted root access for specified users

Introduction

In this tutorial we learn how to install sudo on CentOS 7.

What is sudo

Sudo (superuser do) allows a system administrator to give certain users (or groups of users) the ability to run some (or all) commands as root while logging all commands and arguments. Sudo operates on a per-command basis. It is not a replacement for the shell. Features include user may run on a per-host basis, copious logging of each command (providing a clear audit trail of who did what), a configurable timeout of the sudo command, and the ability to use the same configuration file (sudoers) on many different machines.

We can use yum or dnf to install sudo on CentOS 7. In this tutorial we discuss both methods but you only need to choose one of method to install sudo.

Install sudo on CentOS 7 Using yum

Update yum database with yum using the following command.

sudo yum makecache

After updating yum database, We can install sudo using yum by running the following command:

sudo yum -y install sudo

Install sudo on CentOS 7 Using dnf

If you don’t have dnf installed you can install DNF on CentOS 7 first. Update yum database with dnf using the following command.

sudo dnf makecache

After updating yum database, We can install sudo using dnf by running the following command:

sudo dnf -y install sudo

How To Uninstall sudo on CentOS 7

To uninstall only the sudo package we can use the following command:

sudo dnf remove sudo

References

Summary

In this tutorial we learn how to install sudo on CentOS 7 using yum and dnf.