Linux

How to create a sudo user in CentOS

Sudo users are those users who can execute sudo command. Sudo command grants temporary administrator privileges like authority to install programs, modify system settings and system files.

As these can modify the system settings and cause harm to the system, these privileges are only reserved for the root users. But by using sudo other users can also enjoy this authority. That’s why it’s important to allow only trusted users to be sudo user.

Steps to Create a New Sudo User on CentOS

Step 1: Login into CentOS as the root user

ssh root@server_ip_address

Here replace server_ip_address with the network IP address of your server. Then enter your credentials when prompted.

Step 2: Add a new user to your system

# adduser username

Here remember to replace username with the username you want to have for your new account. (For example, we are creating an account by username lotoftech.)

Step 3: Set a password for the new account

# passwd username

Here again, replace username with the username of your account. You will not see anything while typing the password. Retype the password to make confirmation.

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

Step 4: Add the new user to the sudo group

# usermod -aG wheel username

On CentOS systems, users of wheel group are granted sudo access by default. Hence here we are adding the new user to the wheel group.

This creates a new sudo user in CentOS. Now let’s verify if the newly created sudo user account works.

Verify new sudo user account works

su - username

This command will switch the user account to the new user account created.

username$ sudo command

Run above command while replacing command with whatever you would like to try. You will be asked to enter user account password enter that and you should see command work.

Conclusion:

Here we saw how to create a sudo user in CentOS. We hope you it worked for you. If you face any problem or something is not working for you do tell us in comments.

If you are using a Linux system you know how important a good text editor is. That’s why here are the best text editors for Linux you can try using.

Akash

Recent Posts

Linux Software must have to improve Productivity

You can utilize a wide range of tools as a Linux user to keep organized, manage your time, and become… Read More

2 years ago

How to get Complete details of an Audio Video File

Have you ever caught yourself in a situation where you need details of an audio/ video media file? When you… Read More

4 years ago

Fix Windows 10 showing wrong time in dual boot with Linux

If you have installed Linux alongside windows in the dual boot you might have noticed that every time you boot… Read More

4 years ago

How to update Linux Kernel to the latest version easily

Linux kernel is like the core of the operating system. It's a piece of software that works as a middle… Read More

4 years ago

3 Methods for How to Install Python on Linux System

Nowadays, most Linux Distros already have Python preinstalled. But you might have a distribution that might not have Python preinstalled.… Read More

4 years ago

How to Install Python on Windows 10 to begin coding

Python is one of the most popular and easy to learn programming languages. Its a widely used high-level programming language… Read More

4 years ago

Just so that you know we use cookies on our website. Want to know more

read here