Understanding the /etc/sudoers file

Understanding the /etc/sudoers file

In this tutorial we will discuss about the topic 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

Was this Tutorial helpful? Help others share on Facebook, Twitter, and Google Plus!

 
Enjoyed this video?
Understanding the /etc/sudoers file
"No Thanks. Please Close This Box!"