1

I couldn't help but notice the line in the sudoers file:

root ALL=(ALL:ALL) ALL

From what I understand root already has superuser privileges and doesn't really need to use sudo at all. Am I missing something? Why would root have default sudo privileges when, even when removed from this file, can still do everything it could before? Sorry if the answer is obvious I'm new to linux

2
  • 1
    sudo isn't just for becoming root. Much like su.
    – Daniel B
    Jan 12, 2022 at 9:31
  • 2
    scripts that use sudo would fail for root otherwise
    – stark
    Jan 12, 2022 at 12:11

1 Answer 1

1

The purpose of sudo is to impersonate another user. Root has plenty of reasons to impersonate other users, e.g. testing whether service accounts are set up correctly.

Also, you overlooked a key word in your own question [bold emphasis mine]:

From what I understand root already has superuser privileges and doesn't really need to use sudo at all.

Sure, root doesn't need to use sudo, but they still might accidentally type sudo, and it would be pretty annoying if the command then fails because root is not allowed to use sudo.

It would also make it awkward to write scripts which use sudo and may or may not run under the root account.

You must log in to answer this question.

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