visudo
Permissions
Usage
sudo visudoEdits /etc/sudoers with a lock and a syntax check before saving; editing that file directly and getting it wrong locks everyone out of sudo, which is exactly what visudo prevents.
Common flags
| Flag | Meaning |
|---|---|
| -c | Check the syntax of the current file and exit |
| -f | Edit another sudoers file, such as one under /etc/sudoers.d |
| -s | Check strictly, refusing anything questionable |
| EDITOR= | Set it in front to choose the editor, as in EDITOR=nano |
Examples
sudo visudo -cChecks sudoers for syntax errors.
sudo visudo -f /etc/sudoers.d/deployEdits a drop-in file rather than the main one.
sudo EDITOR=nano visudoUses nano instead of vi.
Numeric and symbolic modes name the same thing: 755 and u=rwx,go=rx are the same permission.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does visudo do?
Edits /etc/sudoers with a lock and a syntax check before saving; editing that file directly and getting it wrong locks everyone out of sudo, which is exactly what visudo prevents.
Q. How do I type it?
sudo visudo — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
4 are listed here; the full set is in man visudo. This command sits under Permissions.
Related commands
man page: man visudo