Linux

Where Is the sudoers File on Linux?

/etc/sudoers and /etc/sudoers.d on Linux, with the visudo rule that keeps a typo from locking out root.

Last updated

sudo rules live in /etc/sudoers with drop-in fragments in /etc/sudoers.d. The main file is root-read-only for good reason.

visudo is mandatory, not advisory. A syntax error in sudoers disables sudo with no self-service recovery except a root shell.

Where Linux stores this, by platform

Linux
/etc/sudoers

Main rules file plus the .d drop-in directory. Always edit via visudo. Custom rules belong in /etc/sudoers.d with 0440 permissions.

Frequently asked questions

How do I safely edit sudoers?

Always edit with visudo (or files under sudoers.d, which visudo also checks). It validates syntax before saving and refuses broken files that would lock out sudo entirely.

Where should custom sudo rules go?

Drop a file in /etc/sudoers.d with a numeric prefix (e.g. 10-admins) and mode 0440. Cleaner than editing the main file and survives package updates to sudoers.

Notice an outdated path? Let us know.