I am quite confused regarding this matter.

As far as I know the user root has all the privelages.

Also all the users of the group sudo has all privelages.

But the user root by default is not a member of the group sudo. Then how can the user root be sudo user?

Please explain the entire concept to me.

To be noted the commands mentioned below produces the output mentioned below:

$root@lenovo:/home/rancho# compgen -u
$root@lenovo:/home/rancho# compgen -g
$root@lenovo:/home/rancho# getent group sudo
$root@lenovo:/home/rancho# getent group root
$root@lenovo:/home/rancho# visudo
# This file MUST be edited with the 'visudo' command as root.
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
# See the man page for details on how to write a sudoers file.
Defaults        rootpw
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

  • This question already has an answer here – wjandrea Jun 16 '16 at 18:43
  • And you can find plenty more information by Googling "sudo vs root" or something similar. – wjandrea Jun 16 '16 at 18:48
  • @wjandrea clearly the two questions are not same. Here I have seperate user whose name is root. It is not about root password. But the user root does not belong to the sudoers group. On the hand only those users who are in the sudoers group can gain root access. And there is no information regarding this by plenty of google searching. Please completely read my question and then comment. – rancho Jun 16 '16 at 18:58
  • Sorry, I guess I didn't understand what you were asking. I'll post an answer. – wjandrea Jun 16 '16 at 19:19

You're correct that root has all privileges, but saying that sudoers have all privileges is not quite correct. They are allowed to attain all privileges by using sudo to run a command as root. That includes running a root prompt, using a command like sudo -i.

root is not a sudoer because it is already root - it doesn't need to become root to run commands.

| improve this answer | |
  • Then if I give the command usermod -a -G sudo root and include root in the group sudo, what difference does it make? – rancho Jun 16 '16 at 19:37
  • I don't think adding root to the sudo group would change anything. Root can already run sudo because it's root. – wjandrea Jun 16 '16 at 19:59
  • After I setup wordpress I get access denied error but after if I include root in sudoers group and myself in root group in addition to sudoers group, the error goes away. Why is that? – rancho Jun 16 '16 at 20:06
  • Note: I am also not present in root group by deafult. I am present in only sudo group. – rancho Jun 16 '16 at 20:08
  • I'm not sure about that Wordpress error, but you shouldn't add yourself to the root group. You are not present in the root group by default for security reasons: the principle of least privilege – wjandrea Jun 16 '16 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.