Mayfield Global Knowledge Center



I receive the message: "<username> is not in the sudoers file. This incident will be reported.". How do I enable sudo?

The sudo command allows users to perform tasks as another user - most commonly, the root user. Using sudo instead of su - has significant advantages. Most notably is that all operations performed with sudo are logged to /var/log/secure.

To use the sudo command, the user (in this article, the user is ned) must be added to the /etc/sudoers configuration file.

  1. At the user terminal, type:su -then press Enter. When prompted, type the root password then press Enter again. The terminal prompt will change from $ to #, indicating that you are now in a root terminal session.
  2. At the root prompt, type:visudo then press Enter. The sudoers file will be displayed.
  3. Press the down arrow, until you locate: ## Allows people in group wheel to run all commands # %wheel ALL=(ALL)       ALL
  4. Uncomment: # %wheel ALL=(ALL)       ALL by deleting the hash (#). The line should now look like:## Allows people in group wheel to run all commands  %wheel ALL=(ALL)       ALL
  5. Write your changes to the file by pressing: Esc (the Escape key) followed by :wq (that's ":"wq).
  6. Now press Enter. You will be returned to the root terminal.
  7. At the root terminal type: groups nedwhere ned is the username of the account that you are adding to sudoers. Press Enter. The result should be similar to:ned : nedThis indicates that the account ned belongs to the group ned.
  8. We will now add the account to the group wheel. Type:usermod -G ned,wheel nedthen press Enter.
     It is important that you remember to add both groups (wheel and ned).
  9. Now type: groups ned then press Enter. The result should be similar to:ned : ned wheelThis indicates that the account ned now belongs to the group ned and the group wheel. You can now run commands using sudo instead of su -.

Would you like to...


del.icio.us

Print this page Print this page

Email this page Email this page

Post a comment Post a comment

Subscribe me

Add to favoritesAdd to favorites

User Opinions (43 votes)

90% thumbs up 9% thumbs down

How would you rate this answer?

Helpful
Not helpful
Thank you for rating this answer.