The sudo command is designed to allow users to run applications with another user’s security rights, by default the root user.
Log in to your CentOS system as the root user.
Create a normal user account called fosnix using the useraad command, the
-m option means to create the user’s home directory if it doesn’t exist,
-s defines the new user’s login shell program (which is
/bin/bash in this case) and
-c defines a comment indicating that this is an administrative user account.
Replace fosnix with the user name that you wish to create and Set a password for the newly created user account using the passwd command
On all Linux distributions that belongs to the RHEL family, only users in the wheel system group can run a command with sudo. So, next, add the new user fosnix to the wheel group using the usermod command. Here, the -a flag means to append user to a supplementary group and -G specifies the group.
Now, you will login with your Username and Password
As the new user, verify that you can use sudo by prepending “sudo” to the command that you want to run with superuser privileges.