Sudo – How to Add a User to Sudoers File

sudo

I have an account named as Chankey (local user). I had to use some commands like viewing the shadow file etc. I tried it using sudo command

sudo vim /etc/shadow

It said:

Chankey is not in the sudoers file. This incident will be reported.

How can I add this user Chankey to the sudoers file?

Best Answer

You need to have root access to add a user to the sudoers file. So either

su - root

(and put the root password in) and then use

visudo

as root to make the relevant and correct changes, or ask your sysadmin.

You usually want something like,

username    ALL=(ALL) ALL

or,

%groupname  ALL=(ALL) ALL

and put your user ID into that group, but how you configure sudo depends on the standards for your environment.

Changing the sudo config file should only ever be done with visudo (to prevent being locked out by making a bad change), and it should only be done by someone who understands how to configure sudo safely (personal soapbox: sudo is not the tool some people think it is).

Related Question