VISUDO(8)
โจ VISUDO(8) โจ
Manual page: visudo(8), from the System Manager's Manual ๐
๐ NAME
visudo โ edit the sudoers file ๐
๐ฆ SYNOPSIS
visudo [-chIOPqsV] [[-f] sudoers]
๐ธ DESCRIPTION
okay so visudo is the bestie that edits your sudoers file safely ๐ซถ It's basically the same vibe as vipw(8). It locks the sudoers file so two people can't edit it at the same time, does some basic validity checks, and checks for syntax errors before it installs your edits. If someone else is already editing it, you'll get a message telling you to try again later ๐ญ
If the sudoers file doesn't exist yet, visudo will create it, unless your editor quits without writing anything to it.
Now, visudo parses the sudoers file after you edit it, and it won't save your changes if there's a syntax error ๐
โโ๏ธ When it finds one, it prints the line number(s) where things went wrong and then you get the โWhat now?โ prompt. From there you can type โeโ to re-edit the file, โxโ to exit without saving, or โQโ to quit and save your changes.
โQโ is giving dangerous energy, so use it with extreme caution ๐ Ifvisudothinks there's a syntax error,sudowill think so too. If you type โeโ after a syntax error has been detected, your cursor will land on the line where the error happened, as long as your editor supports that feature โจ
There are two sudoers settings that decide which editor visudo runs. Let's go through them ๐
editorโ this is a colon (โ:โ) separated list of editors that are allowed to be used withvisudo.visudowill pick the one that matches yourSUDO_EDITOR,VISUAL, orEDITORenvironment variable if it can. If not, it grabs the first editor in the list that exists and is executable. Also,sudowon't preserveSUDO_EDITOR,VISUAL, orEDITORunless they're in theenv_keeplist or theenv_resetoption is disabled in the sudoers file. The default editor path is/usr/bin/editor, which can be changed at compile time with the--with-editorconfigure option ๐env_editorโ if this is set,visudowill use the value ofSUDO_EDITOR,VISUAL, orEDITORbefore falling back on the default editor list. Heads up, though:visudousually runs as root, so this option might let a user with visudo privileges run arbitrary commands as root without logging ๐ณ The safer move is to put a colon-separated list of โsafeโ editors in theeditorvariable. Thenvisudowill only useSUDO_EDITOR,VISUAL, orEDITORif they match a value listed ineditor. If theenv_resetflag is enabled,SUDO_EDITOR,VISUAL, and/orEDITORmust be in theenv_keeplist forenv_editorto work whenvisudois run throughsudo. The default value is on, and you can change that at compile time with the--with-env-editorconfigure option ๐ง
Here are the options, bestie ๐
๐ OPTIONS ๐
-c,--checkโ this turns on check-only mode ๐ The existing sudoers file (and any other files it includes) gets checked for syntax errors. If you didn't specify the path to the sudoers file,visudowill also check the file's ownership and permissions (see the-Oand-Poptions). It prints a message to standard output describing the status of sudoers, unless you used-q. If everything checks out,visudoexits with a value of0. If it runs into an error, it exits with a value of1.-f sudoers,--file=sudoersโ point to an alternate sudoers file location, see below ๐บ๏ธ As of version 1.8.27, you can also give the sudoers path without using the-foption.-h,--helpโ shows a short help message on standard output and then exits ๐โโ๏ธ-I,--no-includesโ this turns off editing of include files, unless there's already a syntax error in them. By default,visudoedits the main sudoers file and any files pulled in with@includeor#includedirectives. Files included with@includediror#includedirare never edited unless they have a syntax error ๐-O,--ownerโ enforces the default ownership (user and group) of the sudoers file ๐ค In edit mode, the owner of the edited file gets set to the default. In check mode (-c), an error is reported if the owner is wrong. This one is on by default if you didn't specify the sudoers file.-P,--permsโ enforces the default permissions (mode) of the sudoers file ๐ In edit mode, the permissions of the edited file get set to the default. In check mode (-c), an error is reported if the file permissions are incorrect. This is also on by default if you didn't specify the sudoers file.-q,--quietโ quiet mode, where the details about syntax errors don't get printed ๐คซ This is only useful when you combine it with-c.-s,--strictโ turns on strict checking of the sudoers file ๐ช If an alias gets referenced but never actually defined, or there's a cycle in an alias,visudotreats it as a syntax error. Heads up:visudocan't tell the difference between an alias and a host name or user name that's made up solely of uppercase letters, digits, and the underscore (โ_โ) character.-V,--versionโ prints the visudo and sudoers grammar versions and then exits ๐ท๏ธ
A sudoers file can be specified instead of the default, /etc/sudoers. The temporary file used is the specified sudoers file with โ.tmpโ appended to it. โ-โ can be used to say that sudoers should be read from standard input, but only in check-only mode. Also, since the policy gets evaluated in its entirety, checking just one individual sudoers include file for syntax errors isn't enough ๐
๐ง Debugging and sudoers plugin arguments ๐ง
visudo versions 1.8.4 and higher have a flexible debugging framework. You configure it with Debug lines in the sudo.conf(5) file ๐ ๏ธ
Starting with sudo 1.8.12, visudo will also parse the arguments given to the sudoers plugin. These let you override the default sudoers path name, user-ID, group-ID, and file mode ๐ If they're present, they should be listed after the path to the plugin (so, after sudoers.so). You can specify multiple arguments, separated by white space. For example:
Plugin sudoers_policy sudoers.so sudoers_mode=0400
These are the arguments that are supported:
sudoers_file=pathnameโ overrides the default path to the sudoers file ๐sudoers_uid=user-IDโ overrides the default owner of the sudoers file. It should be a numeric user-ID.sudoers_gid=group-IDโ overrides the default group of the sudoers file. It must be a numeric group-ID, not a group name ๐ขsudoers_mode=modeโ overrides the default file mode for the sudoers file. It should be an octal value ๐ฆ
For more info on configuring sudo.conf(5), check out its manual ๐
to be continued... ๐
๐ BUGS ๐
okay so if you think you've found a bug in visudo, you've got two options bestie ๐ you can file a bug report in the sudo bug database at https://bugzilla.sudo.ws/, or open an issue at https://github.com/sudo-project/sudo/issues. ๐
if email is more your thing, you can send messages to the sudo-workers mailing list at https://www.sudo.ws/mailman/listinfo/sudo-workers (that one's public ๐ธ) or privately to <sudo@sudo.ws> ๐ซถ
๐จ PLEASE do not report security vulnerabilities through public GitHub issues, Bugzilla, or mailing lists!! ๐ญ instead, email them privately to<Todd.Miller@sudo.ws>. you're allowed to encrypt your message with PGP if you want, using the key found athttps://www.sudo.ws/dist/PGPKEYS๐โจ
๐ SUPPORT ๐
okay so there's limited free support available through the sudo-users mailing list ๐ฆ subscribe or search the archives at https://www.sudo.ws/mailman/listinfo/sudo-users ๐ง
๐ DISCLAIMER ๐
visudo is provided "AS IS" ๐ซ any express or implied warranties, including but not limited to the implied warranties of merchantability and fitness for a particular purpose, are totally disclaimed, no cap ๐ for the complete details, check out the LICENSE.md file distributed with sudo or https://www.sudo.ws/about/license/ ๐
Sudo 1.9.17p2 ๐ July 27, 2023 ๐ VISUDO(8) โ bye bestie, go be a sudoer legend ๐๐
๐ฆ where this page comes from
- ubuntu questing: sudo 1.9.17p2-1ubuntu1
- ubuntu questing: sudo 1.9.17p2-1ubuntu1.1 ยท ISC
- ubuntu resolute: sudo 1.9.17p2-1ubuntu3 ยท ISC
- ubuntu resolute: sudo 1.9.17p2-1ubuntu3.2 ยท ISC
- ubuntu stonking: sudo 1.9.17p2-7ubuntu5 ยท ISC
- ๐ the page's license: ISC
- Copyright (c) 1996,1998-2005, 2007-2023 Todd C. Miller <Todd.Miller@sudo.ws>
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms