Saturday, November 18, 2017

How to add a user in sudoers

How to add a user in sudoers list?

My OS is CentOS release 6.9 (Final). At the moment I have only root user. I need to create a user and add that user in sudoers.

Login to server as root. - ssh {ip}
Create user- useradd {arun}
Password to that user - password {arun}
usermod -aG wheel {arun}
Run - visudo
Scroll down to the bottom where wheel groups are described.

## Allows people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL
{arun}          ALL=(ALL)       ALL

Now login as that user {arun}
sudo ls -la /root

It will ask for password, then list all files in /root directory.