Advance

How to create a new Sudo-enabled user on CentOS 8

How to create a new Sudo-enabled user on CentOS 8
1
(1)

As a system administrator, you may be familiar with sudo command. In this article, you will learn how to create a New Sudo-enabled user on CentOS 8. It provides a mechanism for granting administrator privileges — ordinarily only available to the root user to normal users.

In this tutorial, we are going to show you how to create a new user with sudo access on CentOS 8, without having to modify your server’s /etc/sudoers file.

 

 

How to create a new Sudo-enabled user on CentOS 8

Let’s walk through the following steps to finish this guide. In case you consider to configure an existing CentOS user, skip to step 3.

Recommended Article: Tutorial Install PIP on Windows

Read more, if you are interested in:

initial set up centos 8

1- Logging into your server

First, SSH into your server as the root user. Replace your server’s IP address or hostname in place of the highlighted below.

ssh root@your_server_ip_address      

2- Adding a New User to the System

You can use the adduser command to add a new user to your system and replace noodi with the username you’d like to create.

adduser noodi

Then, to update the new user’s password, use the passwd command.

passwd noodi

Do not forget to replace noodi with the user that you just created. Then you should answer twice for a new password.

Output
Changing password for user noodi.  New password:  Retype new password:  passwd: all authentication tokens updated successfully.

 

Buy VPS server

 

 

3- Adding the User to the wheel group

Next, to add the user to the wheel group, use the usermod command to add the user to the wheel group:

usermod -aG wheel noodi

While all members of the wheel group have full sudo access by default, make sure that you have replaced noodi with the username you’d like to give sudo privileges to.

 

4- Testing sudo access

In this step, you will see if the new sudo permissions are working or not. But to switch from the root user to the new user account, use the su command

su - noodi

Although you are a new user, you need to verify that you can use sudo by prepending sudo to the command that you want to run with superuser privileges.

sudo command_to_run  

Also, you can list the contents of the /root directory, which is normally only accessible to the root user:

sudo ls -la /root

Once you begin to use sudo in a session, you will be asked to enter the password of that user’s account.

Output
[sudo] password for noodi:

Please note: You should enter the sudo-enabled user password, not the root password. because it is not asking you for the root password.

 

Finally, you will see the command that you issued with sudo will run with root privileges, in case your user is in the proper group and you entered the password correctly.

How useful was this post?

Click on a star to rate it!

Average rating 1 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

View More Posts
Tom Veitch
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day