Usually I don’t want to use default root account on Linux (security and practical reasons), so one of my first steps is to create new account that will be “sudo”, an administrative account with system wide privileges.
Here are the steps to create “superuser” account under RHEL\Centos.
Create new sudo user
First, we will need root access in order to create new user:
Enter following command:
su
You will be prompted for root password:
We will now add new user (in my case name is TurboUser) and put new user into group wheel – which is superuser group
useradd -G wheel TurboUser
After user is successfully added, we will change password for him
passwd TurboUser
Log off, and then log on with new user you created (I will login as TurboUser).
Open terminal and type in:
su TurboUser
The last command will show as if we were successful in creating new root user.
Type in:
sudo whoami
You will be prompted for password, and success, TurboUser is root user.
Add existing user to sudoers
I want to add sudo privileges to existing user – informaticar, which is currently simple user.
First enter following command to gain root privileges, and enter your root password:
su
Next, enter following command which will add your user (informaticar in my case) to wheel group.
sudo usermod -aG wheel informaticar
Log off, and then log on again
Open terminal, enter:
su informaticar
sudo whoami
We added user informaticar to superusers.