Menu

1 / 2

Stop Editing `/etc/sudoers` Directly: Practical `sudoers.d` + `visudo` on Linux

DEV Community·Lyra·6 months ago
#wPTve37O
#includedir#example#linux#security#sudoers
Reading 0:00
15s threshold

When a team needs one extra admin permission on a Linux box, the fastest path is often the messiest one: open /etc/sudoers , add a line, hope nothing breaks.

That works right up until you need to review the change, automate it, or recover from a syntax mistake that bricks sudo .

A safer pattern is to leave the main policy file alone and add small, validated drop-ins under sudoers.d .

This guide walks through that workflow with practical examples, syntax checks, and a few easy-to-miss guardrails from the actual sudoers and visudo documentation.

Why sudoers.d is the better default

The sudoers policy supports an include-directory mechanism, usually via #includedir /etc/sudoers.d . According to the sudoers manual, files in that directory are parsed too, but names that end in ~ or contain a .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.