Tuesday, September 22, 2020

How To Create a Sudo User on RHEL (Red Hat Enterprise Linux) Operating System

Must read

How to Change Hostname on Ubuntu 20.04 Linux

The hostname is known as the system's identifier, which is set at the time when we are installing the Ubuntu operating system.

How to Install Node.js and NPM on Debian 10 Linux

The Node.js is the very well-known JavaScript runtime environment used to JavaScript code server-side execution. It is an Open-source, cross-platform supported environment....

How to Install Go on Debian 10 Linux

Go is a very new and most popular open-source programming language; Google creates it. There are many popular software/applications developed using the...

How to Deploy Rocket.Chat on Debian 10 Linux

Rocket.Chat is a very popular open-source team communication system; it is famous as an alternative to Slack. It provides various features along...
SATISH KUMAR
I am Satish Kumar, Founder of LinuxConcept. Linux and F.O.S.S enthusiast, love to work on open source platform and technologies.

We talk about “sudo” privileges, we are talking about the “sudo” command.

The “sudo” command allows users to run any other commands, services, or program with the privileges of another user, and by default, it took the privileges of the root user.

In this tutorial, we will learn how to create a new user with sudo access on Red Hat Operating System. So, you can use this user to execute an administrative command in the system without login as root user in your RHEL machine.

Create a Sudo User

We will create a new user in RHEL machine with sudo privileges in simple four steps. If you want to give sudo privileges to an existing user, just need to add in “wheel” group and for that directly go to step 4.

Step 1: Log in to your server

In the first step, you need to login into your system or server with root user, using the SSH command:

$ ssh [email protected]_ip_address

Step 2: Create a new user account

Now, we will create a new user in this RHEL machine by using ‘adduser” command. Please replace the “user_name” with the user name that you want to create:

$ adduser user_name

Step 3: Set password for Username

You should run the “passwd” command to secure user with password, as show below:

$ passwd user_name

You will get the new screen to set new password for given username, like below:

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

Step 4: Add new user to sudo group

In the RHEL system if you get a member of the wheel group you will get the sudo access. To add a user into the “wheel” group, use the following usermod command:

$ usermod -aG wheel username

Test the sudo access

To check you have sudo access or not, first go to your account login. To this either you login using your username and password or switch to your account using “su” command, as shown below:

$ su - username

Now, run “whoami” command with sudo:

$ sudo whoami

If the user having sudo access, you will get the output of the “whoami” command is “root”:

Output-

root

How to use sudo

To use the sudo privileges with any command is very simple, prefix the command with “sudo” and space as shown below:

$ sudo ls -l /root

In a session, first-time use of “sudo”, you will get a screen to enter the user password:

Output-

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for username:

Conclusion

You have learned how to create a new user in Red Hat System and assign the sudo access or privileges to a user in RHEL machine. Now, you can log in into your Red Hat system or server with your user access and use “sudo” command to run administrative commands.

Feel free to leave a comment if you have any doubt or questions.

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to Change Hostname on Ubuntu 20.04 Linux

The hostname is known as the system's identifier, which is set at the time when we are installing the Ubuntu operating system.

How to Install Node.js and NPM on Debian 10 Linux

The Node.js is the very well-known JavaScript runtime environment used to JavaScript code server-side execution. It is an Open-source, cross-platform supported environment....

How to Install Go on Debian 10 Linux

Go is a very new and most popular open-source programming language; Google creates it. There are many popular software/applications developed using the...

How to Deploy Rocket.Chat on Debian 10 Linux

Rocket.Chat is a very popular open-source team communication system; it is famous as an alternative to Slack. It provides various features along...

How to Install Tomcat 9 on Ubuntu 20.04 Operating System

The Apache Tomcat software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies. Apache...