The sudo command allows regular users to execute commands with administrative/root privileges. By adding any user to predefined sudo group wheel will grant root privileges to execute any command as root user. Any attempt to use the sudo command for the non-sudo user will result in:
user is not in the sudoers file. This incident will be reported.
In this tutorial you will learn:
- How to create sudo user on RHEL 8 / CentOS 8 system.
- How to add existing user to sudoers.
RHEL 8 / CentOS 8 create a new sudo user step by step instructions.
In this section we will be creating a new sudo user account.
Step 1 : Gain root command line access:
# su
Step 2 : Use the useradd command to create a new user eg. foobar and add user to the wheel group.
# useradd -G wheel foobar
Step 3 : Set password to new fooba :
# passwd foobar
Step 4 : Try Re-login we the new sudo user to apply the new settings:
# su foobar
Step 5 : Test sudo permissions:
#sudo whoami
result will be root.