1. You can use ‘usermod’ command to add the user to the wheel group as below:

$ usermod -aG wheel oracle (oracle is the username that I want to add in wheel group)

By default, on CentOS, members of the wheel group have sudo privileges.

2. Update ‘/etc/sudoers’ file as ‘root’ user. Keep a backup of the file first before updating. Add following line after:

## Allow root to run any commands anywhere
root    ALL=(ALL)    ALL

so the final version looks like this

## Allow root to run any commands anywhere
root    ALL=(ALL)    ALL
oracle   ALL=(ALL)    ALL

3. Test sudo access on ‘oracle’ user account

Use the su command to switch ‘oracle’ user account.

$ su – oracle

See if you can browse /root folder:

$sudo ls -lrt /root

Ref: https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-centos-quickstart

Advertisements