14 C
Texas
angeloma
Senior Writer and partner

How to enable sudo on CentOS 8?

In our CentOS 8 system, it is necessary to execute commands with user privileges. To do this we have a tool from the GNU project called sudo. However, it is necessary that the user of the system has the privilege to use it. So, in this post, you will learn how to enable sudo in CentOS 8. This same tutorial is applicable to Oracle Linux 8 and RHEL 8.

Briefly, What is sudo?

Sudo is a small program or utility that is installed on Linux in order to allow commands to be executed with another user’s security privileges. Usually, this other user is the root user. This causes the regular user to temporarily become a super user.

For the same reason, there are sysadmin who do not like to use sudo, because if it is misused it can lead to a security breach. However, in the end, it is up to the users.

So, let us enable it.

Enabling sudo on CentOS 8

- Advertisement -

If during the installation of CentOS 8 you have decided not to create any user, then the first step is to create it.

Open a terminal or SSH session and execute the following command:

:~$ su
:~# adduser [username]

Remember to replace [username] with the username of your choice. Then, a password must be assigned.

:~# passwd [username]

Now that we have our user created we can continue. On the other hand, if you have already created the user, you can omit this part.

For the new user to have the sudo command available, it must first be installed. It is usually installed by default but better to be sure.

:~# dnf install sudo

There are now two ways for the new user to use sudo. The first way is to add this user to the wheel group. All members of the wheel group are authorized to use sudo.

If you decide this way, in the terminal use the following command:

:~# usermod -aG wheel [username]

Remember to replace [username] with the username you have chosen.

However, if you do not want your user to belong to the wheel group for any reason, then we will have another option. We can add the user to arcihvo sudoers and specify that they are authorized to use sudo.

To do this as root user open the file /etc/sudoers

:~# nano /etc/sudoers

Then, find this section:

Allow root to run any commands anywhere
root ALL=(ALL) ALL

And add the following:

[username] ALL=(ALL) ALL
1.- Enabling sudo on Centos 8
1.- Enabling sudo on Centos 8

Remember to change [username] to the new user’s username. Save the changes and close the file.

And that is it.

Conclusion

Sudo is a basic utility to run as super users without being one. This is a great advantage in desktop systems or even in certain circumstances on servers. Simply put, it is one of those things that is always good to have on hand.

On the other hand, if you want to learn how to enable sudo in Debian 10, you can do it with this post:

How to enable sudo on Debian 10 Buster?

Please share this post and join our Telegram channel.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article