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?

  • You may want to use vipw -s for safety.
    – Wildcard
    Jan 27, 2017 at 3:51

1 Answer 1


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


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

You usually want something like,

username    ALL=(ALL) ALL


%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).

  • 4
    +1 for using visudo done that once. Painful mistake. :)
    – chrisjlee
    Dec 26, 2012 at 21:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .