VISUDO(8)

๐Ÿ“ฆ version 1.9.17p2, in ubuntu questing, ubuntu resolute, ubuntu stonking

โœจ 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 ๐Ÿ’€ If visudo thinks there's a syntax error, sudo will 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 with visudo. visudo will pick the one that matches your SUDO_EDITOR, VISUAL, or EDITOR environment variable if it can. If not, it grabs the first editor in the list that exists and is executable. Also, sudo won't preserve SUDO_EDITOR, VISUAL, or EDITOR unless they're in the env_keep list or the env_reset option is disabled in the sudoers file. The default editor path is /usr/bin/editor, which can be changed at compile time with the --with-editor configure option ๐Ÿ“
  • env_editor โ€” if this is set, visudo will use the value of SUDO_EDITOR, VISUAL, or EDITOR before falling back on the default editor list. Heads up, though: visudo usually 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 the editor variable. Then visudo will only use SUDO_EDITOR, VISUAL, or EDITOR if they match a value listed in editor. If the env_reset flag is enabled, SUDO_EDITOR, VISUAL, and/or EDITOR must be in the env_keep list for env_editor to work when visudo is run through sudo. The default value is on, and you can change that at compile time with the --with-env-editor configure 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, visudo will also check the file's ownership and permissions (see the -O and -P options). It prints a message to standard output describing the status of sudoers, unless you used -q. If everything checks out, visudo exits with a value of 0. If it runs into an error, it exits with a value of 1.
  • -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 -f option.
  • -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, visudo edits the main sudoers file and any files pulled in with @include or #include directives. Files included with @includedir or #includedir are 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, visudo treats it as a syntax error. Heads up: visudo can'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 at https://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