Skip to content
shellhacks.dev

sudoers Rule Generator

Generate a sudoers drop-in that lets a user or group run specific commands as root, optionally without a password, with warnings for relative paths and wildcards.

Free · No sign-up · Your inputs stay in your browser

Input

Generate a sudoers rule

Output

sudoers drop-in

208 characters

Install with sudo visudo -f /etc/sudoers.d/deploy, which refuses to save a file with a syntax error; a broken sudoers file locks everyone out of sudo. Files in sudoers.d whose names contain a dot or end in ~ are silently ignored. Check what a user may run with sudo -l -U deploy.

Runs in this browser. Nothing you paste is sent to a server.

Grant commands, not shells

A deploy user that may run systemctl reload nginx cannot do anything else as root. A user that may run systemctl * or a text editor as root can get a root shell, because many programs can spawn one. The sudoers manual describes matching rules, including how arguments are compared.

Always use visudo

A syntax error in sudoers stops sudo working for everyone, and fixing it then needs a root password or recovery mode. visudo -f /etc/sudoers.d/deploy checks the file before saving. Files in sudoers.d whose names contain a dot are skipped silently, which is why the generator replaces dots.

Share

Frequently asked questions

How do I let a user run one command with sudo without a password?
Add a line such as deploy ALL=(root) NOPASSWD: /usr/bin/systemctl reload nginx to a file in /etc/sudoers.d, edited with visudo -f.
How do I list what a user may run with sudo?
sudo -l -U deploy prints the rules that apply to that user.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Go deeper

Suggested reading

Keep planning

Similar tools