How To Install sudo on CentOS 8

sudo is Allows restricted root access for specified users

Introduction

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

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 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 8. In this tutorial we discuss both methods but you only need to choose one of method to install sudo.

Install sudo on CentOS 8 Using dnf

Update yum database with dnf using the following command.

sudo dnf makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

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

sudo dnf -y install sudo

Install sudo on CentOS 8 Using yum

Update yum database with yum using the following command.

sudo yum makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

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

sudo yum -y install sudo

How To Uninstall sudo on CentOS 8

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

sudo dnf remove sudo

sudo Package Contents on CentOS 8

/etc/dnf/protected.d/sudo.conf
/etc/pam.d/sudo
/etc/pam.d/sudo-i
/etc/sudo-ldap.conf
/etc/sudo.conf
/etc/sudoers
/etc/sudoers.d
/usr/bin/cvtsudoers
/usr/bin/sudo
/usr/bin/sudoedit
/usr/bin/sudoreplay
/usr/lib/.build-id
/usr/lib/.build-id/3b
/usr/lib/.build-id/3b/9158f7f5d23addfb3e5a136823511b02d1c888
/usr/lib/.build-id/6a
/usr/lib/.build-id/6a/f11c0113d8b8825e6b3e44ca5720960d1d74f2
/usr/lib/.build-id/6d
/usr/lib/.build-id/6d/267393a84e187c74b551b2aab41e5511fde08a
/usr/lib/.build-id/70
/usr/lib/.build-id/70/3396d1b59485310e70a2ee0e6d489c78af8e2c
/usr/lib/.build-id/9f
/usr/lib/.build-id/9f/6e56a2cc4912f1c7ed7cb28a218182d1d33080
/usr/lib/.build-id/ac
/usr/lib/.build-id/ac/cad3eee60fa619d3d3b42673d9c995cfa132a5
/usr/lib/.build-id/d3
/usr/lib/.build-id/d3/971660924d239d3b9091026984a19c2067db8f
/usr/lib/.build-id/df
/usr/lib/.build-id/df/f2cf3251184efbb34ed25bcbeec09b0cf93cf0
/usr/lib/.build-id/e7
/usr/lib/.build-id/e7/231123e3e175f2a8fec9154f61bbb59e469bf1
/usr/lib/.build-id/f8
/usr/lib/.build-id/f8/e4fbbb6c44493c2b23881a7c856c970d7d650b
/usr/lib/tmpfiles.d/sudo.conf
/usr/libexec/sudo
/usr/libexec/sudo/group_file.so
/usr/libexec/sudo/libsudo_util.so
/usr/libexec/sudo/libsudo_util.so.0
/usr/libexec/sudo/libsudo_util.so.0.0.0
/usr/libexec/sudo/sesh
/usr/libexec/sudo/sudo_noexec.so
/usr/libexec/sudo/sudoers.so
/usr/libexec/sudo/system_group.so
/usr/sbin/visudo
/usr/share/doc/sudo
/usr/share/doc/sudo/CONTRIBUTORS
/usr/share/doc/sudo/HISTORY
/usr/share/doc/sudo/NEWS
/usr/share/doc/sudo/README
/usr/share/doc/sudo/README.LDAP
/usr/share/doc/sudo/TROUBLESHOOTING
/usr/share/doc/sudo/UPGRADE
/usr/share/doc/sudo/examples
/usr/share/doc/sudo/examples/pam.conf
/usr/share/doc/sudo/examples/sudo.conf
/usr/share/doc/sudo/examples/sudoers
/usr/share/doc/sudo/examples/syslog.conf
/usr/share/doc/sudo/schema.ActiveDirectory
/usr/share/doc/sudo/schema.OpenLDAP
/usr/share/doc/sudo/schema.iPlanet
/usr/share/doc/sudo/schema.olcSudo
/usr/share/licenses/sudo
/usr/share/licenses/sudo/LICENSE
/usr/share/locale/ast/LC_MESSAGES/sudo.mo
/usr/share/locale/ast/LC_MESSAGES/sudoers.mo
/usr/share/locale/ca/LC_MESSAGES/sudo.mo
/usr/share/locale/ca/LC_MESSAGES/sudoers.mo
/usr/share/locale/cs/LC_MESSAGES/sudo.mo
/usr/share/locale/cs/LC_MESSAGES/sudoers.mo
/usr/share/locale/da/LC_MESSAGES/sudo.mo
/usr/share/locale/da/LC_MESSAGES/sudoers.mo
/usr/share/locale/de/LC_MESSAGES/sudo.mo
/usr/share/locale/de/LC_MESSAGES/sudoers.mo
/usr/share/locale/el/LC_MESSAGES/sudoers.mo
/usr/share/locale/eo/LC_MESSAGES/sudo.mo
/usr/share/locale/eo/LC_MESSAGES/sudoers.mo
/usr/share/locale/es/LC_MESSAGES/sudo.mo
/usr/share/locale/eu/LC_MESSAGES/sudo.mo
/usr/share/locale/eu/LC_MESSAGES/sudoers.mo
/usr/share/locale/fi/LC_MESSAGES/sudo.mo
/usr/share/locale/fi/LC_MESSAGES/sudoers.mo
/usr/share/locale/fr/LC_MESSAGES/sudo.mo
/usr/share/locale/fr/LC_MESSAGES/sudoers.mo
/usr/share/locale/fur/LC_MESSAGES/sudo.mo
/usr/share/locale/fur/LC_MESSAGES/sudoers.mo
/usr/share/locale/gl/LC_MESSAGES/sudo.mo
/usr/share/locale/hr/LC_MESSAGES/sudo.mo
/usr/share/locale/hr/LC_MESSAGES/sudoers.mo
/usr/share/locale/hu/LC_MESSAGES/sudo.mo
/usr/share/locale/hu/LC_MESSAGES/sudoers.mo
/usr/share/locale/it/LC_MESSAGES/sudo.mo
/usr/share/locale/it/LC_MESSAGES/sudoers.mo
/usr/share/locale/ja/LC_MESSAGES/sudo.mo
/usr/share/locale/ja/LC_MESSAGES/sudoers.mo
/usr/share/locale/ko/LC_MESSAGES/sudo.mo
/usr/share/locale/ko/LC_MESSAGES/sudoers.mo
/usr/share/locale/lt/LC_MESSAGES/sudoers.mo
/usr/share/locale/nb/LC_MESSAGES/sudo.mo
/usr/share/locale/nb/LC_MESSAGES/sudoers.mo
/usr/share/locale/nl/LC_MESSAGES/sudo.mo
/usr/share/locale/nl/LC_MESSAGES/sudoers.mo
/usr/share/locale/nn/LC_MESSAGES/sudo.mo
/usr/share/locale/pl/LC_MESSAGES/sudo.mo
/usr/share/locale/pl/LC_MESSAGES/sudoers.mo
/usr/share/locale/pt/LC_MESSAGES/sudo.mo
/usr/share/locale/pt/LC_MESSAGES/sudoers.mo
/usr/share/locale/pt_BR/LC_MESSAGES/sudo.mo
/usr/share/locale/pt_BR/LC_MESSAGES/sudoers.mo
/usr/share/locale/ru/LC_MESSAGES/sudo.mo
/usr/share/locale/ru/LC_MESSAGES/sudoers.mo
/usr/share/locale/sk/LC_MESSAGES/sudo.mo
/usr/share/locale/sk/LC_MESSAGES/sudoers.mo
/usr/share/locale/sl/LC_MESSAGES/sudo.mo
/usr/share/locale/sl/LC_MESSAGES/sudoers.mo
/usr/share/locale/sr/LC_MESSAGES/sudo.mo
/usr/share/locale/sr/LC_MESSAGES/sudoers.mo
/usr/share/locale/sv/LC_MESSAGES/sudo.mo
/usr/share/locale/sv/LC_MESSAGES/sudoers.mo
/usr/share/locale/tr/LC_MESSAGES/sudo.mo
/usr/share/locale/tr/LC_MESSAGES/sudoers.mo
/usr/share/locale/uk/LC_MESSAGES/sudo.mo
/usr/share/locale/uk/LC_MESSAGES/sudoers.mo
/usr/share/locale/vi/LC_MESSAGES/sudo.mo
/usr/share/locale/vi/LC_MESSAGES/sudoers.mo
/usr/share/locale/zh_CN/LC_MESSAGES/sudo.mo
/usr/share/locale/zh_CN/LC_MESSAGES/sudoers.mo
/usr/share/locale/zh_TW/LC_MESSAGES/sudo.mo
/usr/share/locale/zh_TW/LC_MESSAGES/sudoers.mo
/usr/share/man/man1/cvtsudoers.1.gz
/usr/share/man/man5/sudo-ldap.conf.5.gz
/usr/share/man/man5/sudo.conf.5.gz
/usr/share/man/man5/sudoers.5.gz
/usr/share/man/man5/sudoers.ldap.5.gz
/usr/share/man/man5/sudoers_timestamp.5.gz
/usr/share/man/man8/sudo.8.gz
/usr/share/man/man8/sudoedit.8.gz
/usr/share/man/man8/sudoreplay.8.gz
/usr/share/man/man8/visudo.8.gz
/var/db/sudo
/var/db/sudo/lectured

References

Summary

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