Understanding the /etc/sudoers file

The /etc/sudoers file is the configuration files for sudo. These is the file where the users and groups with root priviledges are stored.

Do not edit the /etc/sudoers by hand, use sudo visudo instead. visudo opens the /etc/sudoers file in the default text editor and gives a warning if you type something wrong in the file:

>>> /etc/sudoers: syntax error near line 21 <<<
What now?
Options are:
(e)dit sudoers file again
e(x)it without saving changes to sudoers file
(Q)uit and save changes to sudoers file (DANGER!)
What now?

Root priviledges to a user:

# User privilege specification
razvan ALL=(ALL) ALL

  • razvan: the user allowed to use sudo
  • ALL: allow sudo from any terminal
  • (ALL): all the users can use sudo
  • ALL: all the commands can be executed

Root priviledges to a group:

# Members of the admin group may gain root privileges
%geeks ALL=(ALL) ALL
[notice the % before the group name]

  • geeks: the group allowed to use sudo
  • ALL: allow sudo from any terminal
  • (ALL): all the users can use sudo
  • ALL: all the commands can be executed

Share and Enjoy

  • Twitter
  • Facebook
  • Google Plus
  • Email
  • RSS
Tagged with: , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>