Where Is the sudoers File?
Where sudo rules live on Linux, and why edits belong in sudoers.d instead of the main file.
Last updated
sudo reads /etc/sudoers plus every file in /etc/sudoers.d (when the #includedir line is present, as on most distros). The main file ships defaults; your rules belong in a fragment.
Permissions are load-bearing: 0440 root:root, or sudo ignores the file. Always edit through visudo, which locks and syntax-checks before saving. A broken sudoers with no root fallback locks you out.
Where sudo stores this, by platform
/etc/sudoers
Main rules file (0440, edit via visudo only). Prefer fragments in /etc/sudoers.d/. Validate with visudo -c before logging out of your last root shell.
Frequently asked questions
How do I add a sudo rule safely?
Create a file under /etc/sudoers.d/ with mode 0440 and validate with visudo -c. Dropping files beats editing the main sudoers: package updates never touch your fragment and one bad file is easier to isolate.
What if visudo reports a syntax error?
Boot to recovery or a live USB, mount the root, and fix the file with visudo from there. sudo validates syntax before installing, which is exactly the protection lost when editing directly. Keep a known-good root shell while testing.
Notice an outdated path? Let us know.