Creating a New Sudo User on CentOS 8, The Easy Way

DigitalOcean Referral Badge
Start your VPS now with FREE $100 credit.

Most of Linux users are already familiar with the sudo command available from the terminal. The sudo command allows user able to run programs or commands with administrator privileges – usually can only be run by root user.

If you ever need to add a new sudo user within your CentOS 8, here’s how do it the right and easy way.

Table of Contents

1. Login to your CentOS 8 server

Login to your server using ssh as root.

$ ssh [email protected]

Replace 202.189.91 with your server IP address. Don’t forget to enter your root password when asked.

2. Create new user & add it to wheel user group

To add a new user to CentOS you can use the adduser command. For example:

$ adduser node35

You can replace node35 with any username you want to create for this user. The next step is to change the password of the newly created user.

$ passwd node35

Again, replace node35 with the username you want to change its password. You’ll be asked to enter the new password twice.

READ:  How To Install PHP 7.0, PHP 7.1 and PHP 7.2 on CentOS 7

If you want to add the user to a certain user group, you can use the usermod command. Since we’re going to give this user sudo access, we might as well add this user to the wheel group.

$ usermod -aG wheel node35

Why add it to wheel group? Well, in CentOS any users that are added to wheel group will automatically granted sudo access.

3. Trying it out

To see if sudo access are working for user node35 simply switch to user node35 using su - node35 command.

Then try this command to see if the user is already granted root access.

$ sudo whoami

The above command should display root as the output.

There you go, you just finish adding a new user and gave it sudo permission. It shouldn’t take more than a minute to do it, right?

Leave a Comment