{
    "content": [
        {
            "type": "text",
            "text": "# SUDO (man)\n\n## NAME\n\nsudo, sudoedit — execute a command as another user\n\n## SYNOPSIS\n\nsudo -h | -K | -k | -V\nsudo -v [-ABkNnS] [-g group] [-h host] [-p prompt] [-u user]\nsudo -l [-ABkNnS] [-g group] [-h host] [-p prompt] [-U user] [-u user] [command [arg ...]]\nsudo  [-ABbEHnPS]  [-C  num]  [-D  directory] [-g group] [-h host] [-p prompt] [-R directory]\n[-r role] [-t type] [-T timeout] [-u user] [VAR=value] [-i | -s] [command [arg ...]]\nsudoedit [-ABkNnS] [-C num] [-D directory] [-g group] [-h host] [-p  prompt]  [-R  directory]\n[-r role] [-t type] [-T timeout] [-u user] file ...\n\n## DESCRIPTION\n\nsudo allows a permitted user to execute a command as the superuser or another user, as speci‐\nfied by the security policy.  The invoking user's real (not effective) user-ID is used to de‐\ntermine the user name with which to query the security policy.\n\n## TLDR\n\n> Execute a single command as the superuser or another user.\n\n- Run a command as the superuser:\n  `sudo {{less /var/log/syslog}}`\n- Edit a file as the superuser with your default editor:\n  `sudo {{-e|--edit}} {{/etc/fstab}}`\n- Run a command as another user and/or group:\n  `sudo {{-u|--user}} {{user}} {{-g|--group}} {{group}} {{id -a}}`\n- Repeat the last command prefixed with `sudo` (only in Bash, Zsh, etc.):\n  `sudo !!`\n- Launch the default shell with superuser privileges and run login-specific files (`.profile`, `.bash_profile`, etc.):\n  `sudo {{-i|--login}}`\n- Launch the default shell with superuser privileges without changing the environment:\n  `sudo {{-s|--shell}}`\n- Launch the default shell as the specified user, loading the user's environment and reading login-specific files (`.profile`, `.bash_profile`, etc.):\n  `sudo {{-i|--login}} {{-u|--user}} {{user}}`\n- List the allowed (and forbidden) commands for the invoking user in longer format:\n  `sudo {{-ll|--list --list}}`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (30 subsections)\n- **COMMAND EXECUTION** (3 subsections)\n- **EXIT VALUE**\n- **SECURITY NOTES**\n- **ENVIRONMENT**\n- **FILES**\n- **EXAMPLES**\n- **DIAGNOSTICS** (14 subsections)\n- **SEE ALSO**\n- **HISTORY**\n- **AUTHORS**\n- **CAVEATS**\n- **BUGS**\n- **SUPPORT**\n- **DISCLAIMER**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "SUDO",
        "section": "",
        "mode": "man",
        "summary": "sudo, sudoedit — execute a command as another user",
        "synopsis": "sudo -h | -K | -k | -V\nsudo -v [-ABkNnS] [-g group] [-h host] [-p prompt] [-u user]\nsudo -l [-ABkNnS] [-g group] [-h host] [-p prompt] [-U user] [-u user] [command [arg ...]]\nsudo  [-ABbEHnPS]  [-C  num]  [-D  directory] [-g group] [-h host] [-p prompt] [-R directory]\n[-r role] [-t type] [-T timeout] [-u user] [VAR=value] [-i | -s] [command [arg ...]]\nsudoedit [-ABkNnS] [-C num] [-D directory] [-g group] [-h host] [-p  prompt]  [-R  directory]\n[-r role] [-t type] [-T timeout] [-u user] file ...",
        "tldr_summary": "Execute a single command as the superuser or another user.",
        "tldr_examples": [
            {
                "description": "Run a command as the superuser",
                "command": "sudo {{less /var/log/syslog}}"
            },
            {
                "description": "Edit a file as the superuser with your default editor",
                "command": "sudo {{-e|--edit}} {{/etc/fstab}}"
            },
            {
                "description": "Run a command as another user and/or group",
                "command": "sudo {{-u|--user}} {{user}} {{-g|--group}} {{group}} {{id -a}}"
            },
            {
                "description": "Repeat the last command prefixed with `sudo` (only in Bash, Zsh, etc.)",
                "command": "sudo !!"
            },
            {
                "description": "Launch the default shell with superuser privileges and run login-specific files (`.profile`, `.bash_profile`, etc.)",
                "command": "sudo {{-i|--login}}"
            },
            {
                "description": "Launch the default shell with superuser privileges without changing the environment",
                "command": "sudo {{-s|--shell}}"
            },
            {
                "description": "Launch the default shell as the specified user, loading the user's environment and reading login-specific files (`.profile`, `.bash_profile`, etc.)",
                "command": "sudo {{-i|--login}} {{-u|--user}} {{user}}"
            },
            {
                "description": "List the allowed (and forbidden) commands for the invoking user in longer format",
                "command": "sudo {{-ll|--list --list}}"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "-A",
                "long": "--askpass",
                "arg": null,
                "description": "Normally, if sudo requires a password, it will read it from the user's terminal. If the -A (askpass) option is specified, a (possibly graphical) helper program is exe‐ cuted to read the user's password and output the password to the standard output. If the SUDOASKPASS environment variable is set, it specifies the path to the helper program. Otherwise, if sudo.conf(5) contains a line specifying the askpass program, that value will be used. For example: # Path to askpass helper program Path askpass /usr/X11R6/bin/ssh-askpass If no askpass program is available, sudo will exit with an error."
            },
            {
                "flag": "-B",
                "long": "--bell",
                "arg": null,
                "description": "Ring the bell as part of the password prompt when a terminal is present. This option has no effect if an askpass program is used."
            },
            {
                "flag": "-b",
                "long": "--background",
                "arg": null,
                "description": "Run the given command in the background. It is not possible to use shell job control to manipulate background processes started by sudo. Most interactive commands will fail to work properly in background mode."
            },
            {
                "flag": "-C",
                "long": "--close-from",
                "arg": null,
                "description": "Close all file descriptors greater than or equal to num before executing a command. Values less than three are not permitted. By default, sudo will close all open file descriptors other than standard input, standard output, and standard error when exe‐ cuting a command. The security policy may restrict the user's ability to use this option. The sudoers policy only permits use of the -C option when the administrator has enabled the closefromoverride option."
            },
            {
                "flag": "-D",
                "long": "--chdir",
                "arg": null,
                "description": "Run the command in the specified directory instead of the current working directory. The security policy may return an error if the user does not have permission to spec‐ ify the working directory."
            },
            {
                "flag": "-E",
                "long": "--preserve-env",
                "arg": null,
                "description": "Indicates to the security policy that the user wishes to preserve their existing en‐ vironment variables. The security policy may return an error if the user does not have permission to preserve the environment."
            },
            {
                "flag": "",
                "long": "--preserve-env",
                "arg": "list",
                "description": "Indicates to the security policy that the user wishes to add the comma-separated list of environment variables to those preserved from the user's environment. The secu‐ rity policy may return an error if the user does not have permission to preserve the environment. This option may be specified multiple times."
            },
            {
                "flag": "-e",
                "long": "--edit",
                "arg": null,
                "description": "Edit one or more files instead of running a command. In lieu of a path name, the string \"sudoedit\" is used when consulting the security policy. If the user is autho‐ rized by the policy, the following steps are taken: 1. Temporary copies are made of the files to be edited with the owner set to the invoking user. 2. The editor specified by the policy is run to edit the temporary files. The sudoers policy uses the SUDOEDITOR, VISUAL and EDITOR environment variables (in that order). If none of SUDOEDITOR, VISUAL or EDITOR are set, the first pro‐ gram listed in the editor sudoers(5) option is used. 3. If they have been modified, the temporary files are copied back to their origi‐ nal location and the temporary versions are removed. To help prevent the editing of unauthorized files, the following restrictions are en‐ forced unless explicitly allowed by the security policy: • Symbolic links may not be edited (version 1.8.15 and higher). • Symbolic links along the path to be edited are not followed when the parent di‐ rectory is writable by the invoking user unless that user is root (version 1.8.16 and higher). • Files located in a directory that is writable by the invoking user may not be edited unless that user is root (version 1.8.16 and higher). Users are never allowed to edit device special files. If the specified file does not exist, it will be created. Unlike most commands run by sudo, the editor is run with the invoking user's environment unmodified. If the temporary file becomes empty after editing, the user will be prompted before it is installed. If, for some reason, sudo is unable to update a file with its edited ver‐ sion, the user will receive a warning and the edited copy will remain in a temporary file."
            },
            {
                "flag": "-g",
                "long": "--group",
                "arg": null,
                "description": "Run the command with the primary group set to group instead of the primary group specified by the target user's password database entry. The group may be either a group name or a numeric group-ID (GID) prefixed with the ‘#’ character (e.g., ‘#0’ for GID 0). When running a command as a GID, many shells require that the ‘#’ be es‐ caped with a backslash (‘\\’). If no -u option is specified, the command will be run as the invoking user. In either case, the primary group will be set to group. The sudoers policy permits any of the target user's groups to be specified via the -g op‐ tion as long as the -P option is not in use."
            },
            {
                "flag": "-H",
                "long": "--set-home",
                "arg": null,
                "description": "Request that the security policy set the HOME environment variable to the home direc‐ tory specified by the target user's password database entry. Depending on the pol‐ icy, this may be the default behavior."
            },
            {
                "flag": "-h",
                "long": "--help",
                "arg": null,
                "description": "Display a short help message to the standard output and exit."
            },
            {
                "flag": "-h",
                "long": "--host",
                "arg": null,
                "description": "Run the command on the specified host if the security policy plugin supports remote commands. The sudoers plugin does not currently support running remote commands. This may also be used in conjunction with the -l option to list a user's privileges for the remote host."
            },
            {
                "flag": "-i",
                "long": "--login",
                "arg": null,
                "description": "Run the shell specified by the target user's password database entry as a login shell. This means that login-specific resource files such as .profile, .bashprofile, or .login will be read by the shell. If a command is specified, it is passed to the shell as a simple command using the -c option. The command and any args are concatenated, separated by spaces, after escaping each character (including white space) with a backslash (‘\\’) except for alphanumerics, underscores, hyphens, and dollar signs. If no command is specified, an interactive shell is executed. sudo attempts to change to that user's home directory before running the shell. The command is run with an environment similar to the one a user would receive at log in. Most shells behave differently when a command is specified as compared to an interac‐ tive session; consult the shell's manual for details. The Command environment sec‐ tion in the sudoers(5) manual documents how the -i option affects the environment in which a command is run when the sudoers policy is in use."
            },
            {
                "flag": "-K",
                "long": "--remove-timestamp",
                "arg": null,
                "description": "Similar to the -k option, except that it removes every cached credential for the user, regardless of the terminal or parent process ID. The next time sudo is run, a password must be entered if the security policy requires authentication. It is not possible to use the -K option in conjunction with a command or other option. This option does not require a password. Not all security policies support credential caching."
            },
            {
                "flag": "-k",
                "long": "--reset-timestamp",
                "arg": null,
                "description": "When used without a command, invalidates the user's cached credentials for the cur‐ rent session. The next time sudo is run in the session, a password must be entered if the security policy requires authentication. By default, the sudoers policy uses a separate record in the credential cache for each terminal (or parent process ID if no terminal is present). This prevents the -k option from interfering with sudo com‐ mands run in a different terminal session. See the timestamptype option in sudoers(5) for more information. This option does not require a password, and was added to allow a user to revoke sudo permissions from a .logout file. When used in conjunction with a command or an option that may require a password, this option will cause sudo to ignore the user's cached credentials. As a result, sudo will prompt for a password (if one is required by the security policy) and will not update the user's cached credentials. Not all security policies support credential caching."
            },
            {
                "flag": "-l",
                "long": "--list",
                "arg": null,
                "description": "If no command is specified, list the privileges for the invoking user (or the user specified by the -U option) on the current host. A longer list format is used if this option is specified multiple times and the security policy supports a verbose output format. If a command is specified and is permitted by the security policy for the invoking user (or the, user specified by the -U option) on the current host, the fully-quali‐ fied path to the command is displayed along with any args. If -l is specified more than once (and the security policy supports it), the matching rule is displayed in a verbose format along with the command. If a command is specified but not allowed by the policy, sudo will exit with a status value of 1."
            },
            {
                "flag": "-N",
                "long": "--no-update",
                "arg": null,
                "description": "Do not update the user's cached credentials, even if the user successfully authenti‐ cates. Unlike the -k flag, existing cached credentials are used if they are valid. To detect when the user's cached credentials are valid (or when no authentication is required), the following can be used: sudo -Nnv Not all security policies support credential caching."
            },
            {
                "flag": "-n",
                "long": "--non-interactive",
                "arg": null,
                "description": "Avoid prompting the user for input of any kind. If a password is required for the command to run, sudo will display an error message and exit."
            },
            {
                "flag": "-P",
                "long": "--preserve-groups",
                "arg": null,
                "description": "Preserve the invoking user's group vector unaltered. By default, the sudoers policy will initialize the group vector to the list of groups the target user is a member of. The real and effective group-IDs, however, are still set to match the target user."
            },
            {
                "flag": "-p",
                "long": "--prompt",
                "arg": null,
                "description": "Use a custom password prompt with optional escape sequences. The following percent (‘%’) escape sequences are supported by the sudoers policy: %H expanded to the host name including the domain name (only if the machine's host name is fully qualified or the fqdn option is set in sudoers(5)) %h expanded to the local host name without the domain name %p expanded to the name of the user whose password is being requested (respects the rootpw, targetpw, and runaspw flags in sudoers(5)) %U expanded to the login name of the user the command will be run as (defaults to root unless the -u option is also specified) %u expanded to the invoking user's login name %% two consecutive ‘%’ characters are collapsed into a single ‘%’ character The custom prompt will override the default prompt specified by either the security policy or the SUDOPROMPT environment variable. On systems that use PAM, the custom prompt will also override the prompt specified by a PAM module unless the passpromptoverride flag is disabled in sudoers."
            },
            {
                "flag": "-R",
                "long": "--chroot",
                "arg": null,
                "description": "Change to the specified root directory (see chroot(8)) before running the command. The security policy may return an error if the user does not have permission to spec‐ ify the root directory."
            },
            {
                "flag": "-r",
                "long": "--role",
                "arg": null,
                "description": "Run the command with an SELinux security context that includes the specified role."
            },
            {
                "flag": "-S",
                "long": "--stdin",
                "arg": null,
                "description": "Write the prompt to the standard error and read the password from the standard input instead of using the terminal device."
            },
            {
                "flag": "-s",
                "long": "--shell",
                "arg": null,
                "description": "Run the shell specified by the SHELL environment variable if it is set or the shell specified by the invoking user's password database entry. If a command is specified, it is passed to the shell as a simple command using the -c option. The command and any args are concatenated, separated by spaces, after escaping each character (including white space) with a backslash (‘\\’) except for alphanumerics, underscores, hyphens, and dollar signs. If no command is specified, an interactive shell is exe‐ cuted. Most shells behave differently when a command is specified as compared to an interactive session; consult the shell's manual for details."
            },
            {
                "flag": "-t",
                "long": "--type",
                "arg": null,
                "description": "Run the command with an SELinux security context that includes the specified type. If no type is specified, the default type is derived from the role."
            },
            {
                "flag": "-U",
                "long": "--other-user",
                "arg": null,
                "description": "Used in conjunction with the -l option to list the privileges for user instead of for the invoking user. The security policy may restrict listing other users' privileges. When using the sudoers policy, the -U option is restricted to the root user and users with either the “list” priviege for the specified user or the ability to run any command as root or user on the current host."
            },
            {
                "flag": "-T",
                "long": "--command-timeout",
                "arg": null,
                "description": "Used to set a timeout for the command. If the timeout expires before the command has exited, the command will be terminated. The security policy may restrict the user's ability to set timeouts. The sudoers policy requires that user-specified timeouts be explicitly enabled."
            },
            {
                "flag": "-u",
                "long": "--user",
                "arg": null,
                "description": "Run the command as a user other than the default target user (usually root). The user may be either a user name or a numeric user-ID (UID) prefixed with the ‘#’ char‐ acter (e.g., ‘#0’ for UID 0). When running commands as a UID, many shells require that the ‘#’ be escaped with a backslash (‘\\’). Some security policies may restrict UIDs to those listed in the password database. The sudoers policy allows UIDs that are not in the password database as long as the targetpw option is not set. Other security policies may not support this."
            },
            {
                "flag": "-V",
                "long": "--version",
                "arg": null,
                "description": "Print the sudo version string as well as the version string of any configured plug‐ ins. If the invoking user is already root, the -V option will display the options passed to configure when sudo was built; plugins may display additional information such as default options."
            },
            {
                "flag": "-v",
                "long": "--validate",
                "arg": null,
                "description": "Update the user's cached credentials, authenticating the user if necessary. For the sudoers plugin, this extends the sudo timeout for another 15 minutes by default, but does not run a command. Not all security policies support cached credentials. -- The -- is used to delimit the end of the sudo options. Subsequent options are passed to the command. Options that take a value may only be specified once unless otherwise indicated in the de‐ scription. This is to help guard against problems caused by poorly written scripts that in‐ voke sudo with user-controlled input. Environment variables to be set for the command may also be passed as options to sudo in the form VAR=value, for example LDLIBRARYPATH=/usr/local/pkg/lib. Environment variables may be subject to restrictions imposed by the security policy plugin. The sudoers policy subjects environment variables passed as options to the same restrictions as existing environment variables with one important difference. If the setenv option is set in sudoers, the command to be run has the SETENV tag set or the command matched is ALL, the user may set variables that would otherwise be forbidden. See sudoers(5) for more information."
            }
        ],
        "examples": [
            "The following examples assume a properly configured security policy.",
            "To get a file listing of an unreadable directory:",
            "$ sudo ls /usr/local/protected",
            "To list the home directory of user yaz on a machine where the file system holding ~yaz is not",
            "exported as root:",
            "$ sudo -u yaz ls ~yaz",
            "To edit the index.html file as user www:",
            "$ sudoedit -u www ~www/htdocs/index.html",
            "To view system logs only accessible to root and users in the adm group:",
            "$ sudo -g adm more /var/log/syslog",
            "To run an editor as jim with a different primary group:",
            "$ sudoedit -u jim -g audio ~jim/sound.txt",
            "To shut down a machine:",
            "$ sudo shutdown -r +15 \"quick reboot\"",
            "To make a usage listing of the directories in the /home partition.  The commands are run in a",
            "sub-shell to allow the ‘cd’ command and file redirection to work.",
            "$ sudo sh -c \"cd /home ; du -s * | sort -rn > USAGE\""
        ],
        "see_also": [
            {
                "name": "su",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/su/1/json"
            },
            {
                "name": "stat",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/stat/2/json"
            },
            {
                "name": "logincap",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/logincap/3/json"
            },
            {
                "name": "passwd",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/passwd/5/json"
            },
            {
                "name": "sudo.conf",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/sudo.conf/5/json"
            },
            {
                "name": "sudoplugin",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/sudoplugin/5/json"
            },
            {
                "name": "sudoers",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/sudoers/5/json"
            },
            {
                "name": "sudoerstimestamp",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/sudoerstimestamp/5/json"
            },
            {
                "name": "sudoreplay",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/sudoreplay/8/json"
            },
            {
                "name": "visudo",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/visudo/8/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 33,
                "subsections": [
                    {
                        "name": "-A --askpass",
                        "lines": 12,
                        "flag": "-A",
                        "long": "--askpass"
                    },
                    {
                        "name": "-B --bell",
                        "lines": 3,
                        "flag": "-B",
                        "long": "--bell"
                    },
                    {
                        "name": "-b --background",
                        "lines": 4,
                        "flag": "-b",
                        "long": "--background"
                    },
                    {
                        "name": "-C _ --close-from",
                        "lines": 7,
                        "flag": "-C",
                        "long": "--close-from"
                    },
                    {
                        "name": "-D _ --chdir",
                        "lines": 4,
                        "flag": "-D",
                        "long": "--chdir"
                    },
                    {
                        "name": "-E --preserve-env",
                        "lines": 4,
                        "flag": "-E",
                        "long": "--preserve-env"
                    },
                    {
                        "name": "--preserve-env=list",
                        "lines": 5,
                        "long": "--preserve-env",
                        "arg": "list"
                    },
                    {
                        "name": "-e --edit",
                        "lines": 36,
                        "flag": "-e",
                        "long": "--edit"
                    },
                    {
                        "name": "-g _ --group",
                        "lines": 9,
                        "flag": "-g",
                        "long": "--group"
                    },
                    {
                        "name": "-H --set-home",
                        "lines": 4,
                        "flag": "-H",
                        "long": "--set-home"
                    },
                    {
                        "name": "-h --help",
                        "lines": 2,
                        "flag": "-h",
                        "long": "--help"
                    },
                    {
                        "name": "-h _ --host",
                        "lines": 5,
                        "flag": "-h",
                        "long": "--host"
                    },
                    {
                        "name": "-i --login",
                        "lines": 14,
                        "flag": "-i",
                        "long": "--login"
                    },
                    {
                        "name": "-K --remove-timestamp",
                        "lines": 7,
                        "flag": "-K",
                        "long": "--remove-timestamp"
                    },
                    {
                        "name": "-k --reset-timestamp",
                        "lines": 16,
                        "flag": "-k",
                        "long": "--reset-timestamp"
                    },
                    {
                        "name": "-l --list",
                        "lines": 12,
                        "flag": "-l",
                        "long": "--list"
                    },
                    {
                        "name": "-N --no-update",
                        "lines": 9,
                        "flag": "-N",
                        "long": "--no-update"
                    },
                    {
                        "name": "-n --non-interactive",
                        "lines": 3,
                        "flag": "-n",
                        "long": "--non-interactive"
                    },
                    {
                        "name": "-P --preserve-groups",
                        "lines": 5,
                        "flag": "-P",
                        "long": "--preserve-groups"
                    },
                    {
                        "name": "-p _ --prompt",
                        "lines": 23,
                        "flag": "-p",
                        "long": "--prompt"
                    },
                    {
                        "name": "-R _ --chroot",
                        "lines": 4,
                        "flag": "-R",
                        "long": "--chroot"
                    },
                    {
                        "name": "-r _ --role",
                        "lines": 2,
                        "flag": "-r",
                        "long": "--role"
                    },
                    {
                        "name": "-S --stdin",
                        "lines": 3,
                        "flag": "-S",
                        "long": "--stdin"
                    },
                    {
                        "name": "-s --shell",
                        "lines": 9,
                        "flag": "-s",
                        "long": "--shell"
                    },
                    {
                        "name": "-t _ --type",
                        "lines": 3,
                        "flag": "-t",
                        "long": "--type"
                    },
                    {
                        "name": "-U _ --other-user",
                        "lines": 6,
                        "flag": "-U",
                        "long": "--other-user"
                    },
                    {
                        "name": "-T _ --command-timeout",
                        "lines": 5,
                        "flag": "-T",
                        "long": "--command-timeout"
                    },
                    {
                        "name": "-u _ --user",
                        "lines": 8,
                        "flag": "-u",
                        "long": "--user"
                    },
                    {
                        "name": "-V --version",
                        "lines": 5,
                        "flag": "-V",
                        "long": "--version"
                    },
                    {
                        "name": "-v --validate",
                        "lines": 19,
                        "flag": "-v",
                        "long": "--validate"
                    }
                ]
            },
            {
                "name": "COMMAND EXECUTION",
                "lines": 23,
                "subsections": [
                    {
                        "name": "Process model",
                        "lines": 32
                    },
                    {
                        "name": "Signal handling",
                        "lines": 20
                    },
                    {
                        "name": "Plugins",
                        "lines": 7
                    }
                ]
            },
            {
                "name": "EXIT VALUE",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "SECURITY NOTES",
                "lines": 30,
                "subsections": []
            },
            {
                "name": "ENVIRONMENT",
                "lines": 45,
                "subsections": []
            },
            {
                "name": "FILES",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 32,
                "subsections": []
            },
            {
                "name": "DIAGNOSTICS",
                "lines": 2,
                "subsections": [
                    {
                        "name": "editing files in a writable directory is not permitted",
                        "lines": 5
                    },
                    {
                        "name": "editing symbolic links is not permitted",
                        "lines": 3
                    },
                    {
                        "name": "effective uid is not 0, is sudo installed setuid root?",
                        "lines": 5
                    },
                    {
                        "name": "effective uid is not 0, is sudo on a file system with the 'nosuid' option set or an NFS  file",
                        "lines": 6
                    },
                    {
                        "name": "fatal error, unable to load plugins",
                        "lines": 2
                    },
                    {
                        "name": "invalid environment variable name",
                        "lines": 4
                    },
                    {
                        "name": "no password was provided",
                        "lines": 4
                    },
                    {
                        "name": "a terminal is required to read the password",
                        "lines": 5
                    },
                    {
                        "name": "no writable temporary directory found",
                        "lines": 10
                    },
                    {
                        "name": "sudo must be owned by uid 0 and have the setuid bit set",
                        "lines": 3
                    },
                    {
                        "name": "sudoedit is not supported on this platform",
                        "lines": 3
                    },
                    {
                        "name": "timed out reading password",
                        "lines": 3
                    },
                    {
                        "name": "you do not exist in the passwd database",
                        "lines": 2
                    },
                    {
                        "name": "you may not specify environment variables in edit mode",
                        "lines": 3
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "HISTORY",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "CAVEATS",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SUPPORT",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "DISCLAIMER",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "sudo, sudoedit — execute a command as another user\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "sudo -h | -K | -k | -V\nsudo -v [-ABkNnS] [-g group] [-h host] [-p prompt] [-u user]\nsudo -l [-ABkNnS] [-g group] [-h host] [-p prompt] [-U user] [-u user] [command [arg ...]]\nsudo  [-ABbEHnPS]  [-C  num]  [-D  directory] [-g group] [-h host] [-p prompt] [-R directory]\n[-r role] [-t type] [-T timeout] [-u user] [VAR=value] [-i | -s] [command [arg ...]]\nsudoedit [-ABkNnS] [-C num] [-D directory] [-g group] [-h host] [-p  prompt]  [-R  directory]\n[-r role] [-t type] [-T timeout] [-u user] file ...\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "sudo allows a permitted user to execute a command as the superuser or another user, as speci‐\nfied by the security policy.  The invoking user's real (not effective) user-ID is used to de‐\ntermine the user name with which to query the security policy.\n\nsudo  supports  a  plugin architecture for security policies, auditing, and input/output log‐\nging.  Third parties can develop and distribute their own plugins to work seamlessly with the\nsudo front-end.  The default security policy is sudoers, which is  configured  via  the  file\n/etc/sudoers, or via LDAP.  See the “Plugins” section for more information.\n\nThe  security  policy determines what privileges, if any, a user has to run sudo.  The policy\nmay require that users authenticate themselves with  a  password  or  another  authentication\nmechanism.   If  authentication is required, sudo will exit if the user's password is not en‐\ntered within a configurable time limit.  This limit is policy-specific; the default  password\nprompt timeout for the sudoers security policy is 0 minutes.\n\nSecurity  policies  may  support credential caching to allow the user to run sudo again for a\nperiod of time without requiring authentication.  By default, the sudoers policy caches  cre‐\ndentials   on   a   per-terminal   basis   for   15  minutes.   See  the  timestamptype  and\ntimestamptimeout options in sudoers(5) for more information.  By running sudo  with  the  -v\noption, a user can update the cached credentials without running a command.\n\nOn systems where sudo is the primary method of gaining superuser privileges, it is imperative\nto  avoid syntax errors in the security policy configuration files.  For the default security\npolicy, sudoers(5), changes to the configuration files should be  made  using  the  visudo(8)\nutility which will ensure that no syntax errors are introduced.\n\nWhen invoked as sudoedit, the -e option (described below), is implied.\n\nSecurity  policies  and audit plugins may log successful and failed attempts to run sudo.  If\nan I/O plugin is configured, the running command's input and output may be logged as well.\n\nThe options are as follows:\n",
                "subsections": [
                    {
                        "name": "-A --askpass",
                        "content": "Normally, if sudo requires a password, it will read it from the user's terminal.   If\nthe  -A  (askpass) option is specified, a (possibly graphical) helper program is exe‐\ncuted to read the user's password and output the password to the standard output.  If\nthe SUDOASKPASS environment variable is set, it specifies the  path  to  the  helper\nprogram.   Otherwise, if sudo.conf(5) contains a line specifying the askpass program,\nthat value will be used.  For example:\n\n# Path to askpass helper program\nPath askpass /usr/X11R6/bin/ssh-askpass\n\nIf no askpass program is available, sudo will exit with an error.\n",
                        "flag": "-A",
                        "long": "--askpass"
                    },
                    {
                        "name": "-B --bell",
                        "content": "Ring the bell as part of the password prompt when a terminal is present.  This option\nhas no effect if an askpass program is used.\n",
                        "flag": "-B",
                        "long": "--bell"
                    },
                    {
                        "name": "-b --background",
                        "content": "Run the given command in the background.  It is not possible to use shell job control\nto manipulate background processes started by sudo.  Most interactive  commands  will\nfail to work properly in background mode.\n",
                        "flag": "-b",
                        "long": "--background"
                    },
                    {
                        "name": "-C _ --close-from",
                        "content": "Close  all  file descriptors greater than or equal to num before executing a command.\nValues less than three are not permitted.  By default, sudo will close all open  file\ndescriptors  other than standard input, standard output, and standard error when exe‐\ncuting a command.  The security policy may restrict the user's ability  to  use  this\noption.   The sudoers policy only permits use of the -C option when the administrator\nhas enabled the closefromoverride option.\n",
                        "flag": "-C",
                        "long": "--close-from"
                    },
                    {
                        "name": "-D _ --chdir",
                        "content": "Run the command in the specified directory instead of the current working  directory.\nThe security policy may return an error if the user does not have permission to spec‐\nify the working directory.\n",
                        "flag": "-D",
                        "long": "--chdir"
                    },
                    {
                        "name": "-E --preserve-env",
                        "content": "Indicates  to the security policy that the user wishes to preserve their existing en‐\nvironment variables.  The security policy may return an error if the  user  does  not\nhave permission to preserve the environment.\n",
                        "flag": "-E",
                        "long": "--preserve-env"
                    },
                    {
                        "name": "--preserve-env=list",
                        "content": "Indicates to the security policy that the user wishes to add the comma-separated list\nof  environment  variables to those preserved from the user's environment.  The secu‐\nrity policy may return an error if the user does not have permission to preserve  the\nenvironment.  This option may be specified multiple times.\n",
                        "long": "--preserve-env",
                        "arg": "list"
                    },
                    {
                        "name": "-e --edit",
                        "content": "Edit  one  or  more  files instead of running a command.  In lieu of a path name, the\nstring \"sudoedit\" is used when consulting the security policy.  If the user is autho‐\nrized by the policy, the following steps are taken:\n\n1.   Temporary copies are made of the files to be edited with the owner  set  to  the\ninvoking user.\n\n2.   The  editor  specified  by  the  policy is run to edit the temporary files.  The\nsudoers policy uses the SUDOEDITOR, VISUAL and EDITOR environment variables (in\nthat order).  If none of SUDOEDITOR, VISUAL or EDITOR are set, the  first  pro‐\ngram listed in the editor sudoers(5) option is used.\n\n3.   If  they have been modified, the temporary files are copied back to their origi‐\nnal location and the temporary versions are removed.\n\nTo help prevent the editing of unauthorized files, the following restrictions are en‐\nforced unless explicitly allowed by the security policy:\n\n•  Symbolic links may not be edited (version 1.8.15 and higher).\n\n•  Symbolic links along the path to be edited are not followed when the  parent  di‐\nrectory is writable by the invoking user unless that user is root (version 1.8.16\nand higher).\n\n•  Files  located  in  a  directory that is writable by the invoking user may not be\nedited unless that user is root (version 1.8.16 and higher).\n\nUsers are never allowed to edit device special files.\n\nIf the specified file does not exist, it will be created.  Unlike most  commands  run\nby  sudo,  the editor is run with the invoking user's environment unmodified.  If the\ntemporary file becomes empty after editing, the user will be prompted  before  it  is\ninstalled.  If, for some reason, sudo is unable to update a file with its edited ver‐\nsion,  the user will receive a warning and the edited copy will remain in a temporary\nfile.\n",
                        "flag": "-e",
                        "long": "--edit"
                    },
                    {
                        "name": "-g _ --group",
                        "content": "Run the command with the primary group set to group  instead  of  the  primary  group\nspecified  by  the  target user's password database entry.  The group may be either a\ngroup name or a numeric group-ID (GID) prefixed with the ‘#’  character  (e.g.,  ‘#0’\nfor GID 0).  When running a command as a GID, many shells require that the ‘#’ be es‐\ncaped  with a backslash (‘\\’).  If no -u option is specified, the command will be run\nas the invoking user.  In either case, the primary group will be set to  group.   The\nsudoers policy permits any of the target user's groups to be specified via the -g op‐\ntion as long as the -P option is not in use.\n",
                        "flag": "-g",
                        "long": "--group"
                    },
                    {
                        "name": "-H --set-home",
                        "content": "Request that the security policy set the HOME environment variable to the home direc‐\ntory  specified  by the target user's password database entry.  Depending on the pol‐\nicy, this may be the default behavior.\n",
                        "flag": "-H",
                        "long": "--set-home"
                    },
                    {
                        "name": "-h --help",
                        "content": "Display a short help message to the standard output and exit.\n",
                        "flag": "-h",
                        "long": "--help"
                    },
                    {
                        "name": "-h _ --host",
                        "content": "Run the command on the specified host if the security policy plugin  supports  remote\ncommands. The sudoers plugin does not currently support running remote commands. This\nmay  also  be  used in conjunction with the -l option to list a user's privileges for\nthe remote host.\n",
                        "flag": "-h",
                        "long": "--host"
                    },
                    {
                        "name": "-i --login",
                        "content": "Run the shell specified by the target user's  password  database  entry  as  a  login\nshell.    This   means   that   login-specific   resource  files  such  as  .profile,\n.bashprofile, or .login will be read by the shell.  If a command is specified, it is\npassed to the shell as a simple command using the -c option.   The  command  and  any\nargs  are concatenated, separated by spaces, after escaping each character (including\nwhite space) with a backslash (‘\\’) except for alphanumerics,  underscores,  hyphens,\nand  dollar  signs.   If  no  command is specified, an interactive shell is executed.\nsudo attempts to change to that user's home directory before running the shell.   The\ncommand is run with an environment similar to the one a user would receive at log in.\nMost shells behave differently when a command is specified as compared to an interac‐\ntive  session;  consult the shell's manual for details.  The Command environment sec‐\ntion in the sudoers(5) manual documents how the -i option affects the environment  in\nwhich a command is run when the sudoers policy is in use.\n",
                        "flag": "-i",
                        "long": "--login"
                    },
                    {
                        "name": "-K --remove-timestamp",
                        "content": "Similar  to  the  -k  option,  except that it removes every cached credential for the\nuser, regardless of the terminal or parent process ID.  The next time sudo is run,  a\npassword  must  be entered if the security policy requires authentication.  It is not\npossible to use the -K option in conjunction with a command or  other  option.   This\noption  does  not  require  a password.  Not all security policies support credential\ncaching.\n",
                        "flag": "-K",
                        "long": "--remove-timestamp"
                    },
                    {
                        "name": "-k --reset-timestamp",
                        "content": "When used without a command, invalidates the user's cached credentials for  the  cur‐\nrent  session.   The next time sudo is run in the session, a password must be entered\nif the security policy requires authentication.  By default, the sudoers policy  uses\na  separate record in the credential cache for each terminal (or parent process ID if\nno terminal is present).  This prevents the -k option from interfering with sudo com‐\nmands run in  a  different  terminal  session.   See  the  timestamptype  option  in\nsudoers(5)  for  more  information.  This option does not require a password, and was\nadded to allow a user to revoke sudo permissions from a .logout file.\n\nWhen used in conjunction with a command or an option that  may  require  a  password,\nthis  option  will  cause sudo to ignore the user's cached credentials.  As a result,\nsudo will prompt for a password (if one is required by the security policy) and  will\nnot update the user's cached credentials.\n\nNot all security policies support credential caching.\n",
                        "flag": "-k",
                        "long": "--reset-timestamp"
                    },
                    {
                        "name": "-l --list",
                        "content": "If  no  command  is specified, list the privileges for the invoking user (or the user\nspecified by the -U option) on the current host.  A longer list  format  is  used  if\nthis  option  is  specified multiple times and the security policy supports a verbose\noutput format.\n\nIf a command is specified and is permitted by the security policy  for  the  invoking\nuser  (or the, user specified by the -U option) on the current host, the fully-quali‐\nfied path to the command is displayed along with any args. If -l  is  specified  more\nthan  once (and the security policy supports it), the matching rule is displayed in a\nverbose format along with the command.  If a command is specified but not allowed  by\nthe policy, sudo will exit with a status value of 1.\n",
                        "flag": "-l",
                        "long": "--list"
                    },
                    {
                        "name": "-N --no-update",
                        "content": "Do  not update the user's cached credentials, even if the user successfully authenti‐\ncates.  Unlike the -k flag, existing cached credentials are used if they  are  valid.\nTo  detect when the user's cached credentials are valid (or when no authentication is\nrequired), the following can be used:\n\nsudo -Nnv\n\nNot all security policies support credential caching.\n",
                        "flag": "-N",
                        "long": "--no-update"
                    },
                    {
                        "name": "-n --non-interactive",
                        "content": "Avoid prompting the user for input of any kind.  If a password is  required  for  the\ncommand to run, sudo will display an error message and exit.\n",
                        "flag": "-n",
                        "long": "--non-interactive"
                    },
                    {
                        "name": "-P --preserve-groups",
                        "content": "Preserve  the invoking user's group vector unaltered.  By default, the sudoers policy\nwill initialize the group vector to the list of groups the target user  is  a  member\nof.   The  real  and  effective group-IDs, however, are still set to match the target\nuser.\n",
                        "flag": "-P",
                        "long": "--preserve-groups"
                    },
                    {
                        "name": "-p _ --prompt",
                        "content": "Use a custom password prompt with optional escape sequences.  The  following  percent\n(‘%’) escape sequences are supported by the sudoers policy:\n\n%H  expanded  to  the host name including the domain name (only if the machine's host\nname is fully qualified or the fqdn option is set in sudoers(5))\n\n%h  expanded to the local host name without the domain name\n\n%p  expanded to the name of the user whose password is being requested (respects  the\nrootpw, targetpw, and runaspw flags in sudoers(5))\n\n%U  expanded  to  the  login name of the user the command will be run as (defaults to\nroot unless the -u option is also specified)\n\n%u  expanded to the invoking user's login name\n\n%%  two consecutive ‘%’ characters are collapsed into a single ‘%’ character\n\nThe custom prompt will override the default prompt specified by either  the  security\npolicy  or the SUDOPROMPT environment variable.  On systems that use PAM, the custom\nprompt  will  also  override  the  prompt  specified  by  a  PAM  module  unless  the\npasspromptoverride flag is disabled in sudoers.\n",
                        "flag": "-p",
                        "long": "--prompt"
                    },
                    {
                        "name": "-R _ --chroot",
                        "content": "Change  to  the  specified root directory (see chroot(8)) before running the command.\nThe security policy may return an error if the user does not have permission to spec‐\nify the root directory.\n",
                        "flag": "-R",
                        "long": "--chroot"
                    },
                    {
                        "name": "-r _ --role",
                        "content": "Run the command with an SELinux security context that includes the specified role.\n",
                        "flag": "-r",
                        "long": "--role"
                    },
                    {
                        "name": "-S --stdin",
                        "content": "Write the prompt to the standard error and read the password from the standard  input\ninstead of using the terminal device.\n",
                        "flag": "-S",
                        "long": "--stdin"
                    },
                    {
                        "name": "-s --shell",
                        "content": "Run  the  shell specified by the SHELL environment variable if it is set or the shell\nspecified by the invoking user's password database entry.  If a command is specified,\nit is passed to the shell as a simple command using the -c option.  The  command  and\nany  args  are  concatenated,  separated  by  spaces,  after  escaping each character\n(including white space) with a backslash (‘\\’) except for alphanumerics, underscores,\nhyphens, and dollar signs.  If no command is specified, an interactive shell is  exe‐\ncuted.   Most shells behave differently when a command is specified as compared to an\ninteractive session; consult the shell's manual for details.\n",
                        "flag": "-s",
                        "long": "--shell"
                    },
                    {
                        "name": "-t _ --type",
                        "content": "Run the command with an SELinux security context that includes  the  specified  type.\nIf no type is specified, the default type is derived from the role.\n",
                        "flag": "-t",
                        "long": "--type"
                    },
                    {
                        "name": "-U _ --other-user",
                        "content": "Used in conjunction with the -l option to list the privileges for user instead of for\nthe invoking user.  The security policy may restrict listing other users' privileges.\nWhen using the sudoers policy, the -U option is restricted to the root user and users\nwith  either  the  “list”  priviege  for the specified user or the ability to run any\ncommand as root or user on the current host.\n",
                        "flag": "-U",
                        "long": "--other-user"
                    },
                    {
                        "name": "-T _ --command-timeout",
                        "content": "Used to set a timeout for the command.  If the timeout expires before the command has\nexited, the command will be terminated.  The security policy may restrict the  user's\nability to set timeouts.  The sudoers policy requires that user-specified timeouts be\nexplicitly enabled.\n",
                        "flag": "-T",
                        "long": "--command-timeout"
                    },
                    {
                        "name": "-u _ --user",
                        "content": "Run  the  command  as  a user other than the default target user (usually root).  The\nuser may be either a user name or a numeric user-ID (UID) prefixed with the ‘#’ char‐\nacter (e.g., ‘#0’ for UID 0).  When running commands as a UID,  many  shells  require\nthat  the ‘#’ be escaped with a backslash (‘\\’).  Some security policies may restrict\nUIDs to those listed in the password database.  The sudoers policy allows  UIDs  that\nare  not  in  the password database as long as the targetpw option is not set.  Other\nsecurity policies may not support this.\n",
                        "flag": "-u",
                        "long": "--user"
                    },
                    {
                        "name": "-V --version",
                        "content": "Print the sudo version string as well as the version string of any  configured  plug‐\nins.   If  the  invoking user is already root, the -V option will display the options\npassed to configure when sudo was built; plugins may display  additional  information\nsuch as default options.\n",
                        "flag": "-V",
                        "long": "--version"
                    },
                    {
                        "name": "-v --validate",
                        "content": "Update  the user's cached credentials, authenticating the user if necessary.  For the\nsudoers plugin, this extends the sudo timeout for another 15 minutes by default,  but\ndoes not run a command.  Not all security policies support cached credentials.\n\n--      The -- is used to delimit the end of the sudo options.  Subsequent options are passed\nto the command.\n\nOptions  that  take  a value may only be specified once unless otherwise indicated in the de‐\nscription.  This is to help guard against problems caused by poorly written scripts that  in‐\nvoke sudo with user-controlled input.\n\nEnvironment  variables to be set for the command may also be passed as options to sudo in the\nform VAR=value, for example LDLIBRARYPATH=/usr/local/pkg/lib.  Environment variables may be\nsubject to restrictions imposed by the security policy plugin.  The sudoers  policy  subjects\nenvironment  variables  passed  as  options  to the same restrictions as existing environment\nvariables with one important difference.  If the setenv option is set in sudoers, the command\nto be run has the SETENV tag set or the command matched is ALL, the user  may  set  variables\nthat would otherwise be forbidden.  See sudoers(5) for more information.\n",
                        "flag": "-v",
                        "long": "--validate"
                    }
                ]
            },
            "COMMAND EXECUTION": {
                "content": "When sudo executes a command, the security policy specifies the execution environment for the\ncommand.   Typically, the real and effective user and group and IDs are set to match those of\nthe target user, as specified in the password database, and the group vector  is  initialized\nbased on the group database (unless the -P option was specified).\n\nThe following parameters may be specified by security policy:\n\n•  real and effective user-ID\n\n•  real and effective group-ID\n\n•  supplementary group-IDs\n\n•  the environment list\n\n•  current working directory\n\n•  file creation mode mask (umask)\n\n•  SELinux role and type\n\n•  scheduling priority (aka nice value)\n",
                "subsections": [
                    {
                        "name": "Process model",
                        "content": "There are two distinct ways sudo can run a command.\n\nIf an I/O logging plugin is configured to log terminal I/O, or if the security policy explic‐\nitly  requests it, a new pseudo-terminal (“pty”) is allocated and fork(2) is used to create a\nsecond sudo process, referred to as the monitor.  The monitor creates a new terminal  session\nwith  itself as the leader and the pty as its controlling terminal, calls fork(2) again, sets\nup the execution environment as described above, and then uses the execve(2) system  call  to\nrun  the  command  in the child process.  The monitor exists to relay job control signals be‐\ntween the user's terminal and the pty the command is being run in.  This makes it possible to\nsuspend and resume the command normally.  Without the monitor, the command would be  in  what\nPOSIX terms an “orphaned process group” and it would not receive any job control signals from\nthe  kernel.   When  the  command  exits or is terminated by a signal, the monitor passes the\ncommand's exit status to the main sudo process and exits.  After receiving the command's exit\nstatus, the main sudo process passes the command's exit status to the security policy's close\nfunction, as well as the close function of any configured audit plugin, and exits.  This mode\nis the default for sudo versions 1.9.14 and above when using the sudoers policy.\n\nIf no pty is used, sudo calls fork(2), sets up the execution environment as described  above,\nand  uses  the  execve(2) system call to run the command in the child process.  The main sudo\nprocess waits until the command has completed, then passes the command's exit status  to  the\nsecurity policy's close function, as well as the close function of any configured audit plug‐\nins,  and  exits.   As a special case, if the policy plugin does not define a close function,\nsudo will execute the command directly instead of calling fork(2) first.  The sudoers  policy\nplugin  will  only define a close function when I/O logging is enabled, a pty is required, an\nSELinux role is specified, the command has an  associated  timeout,  or  the  pamsession  or\npamsetcred  options are enabled.  Both pamsession and pamsetcred are enabled by default on\nsystems using PAM.  This mode is the default for sudo versions prior to 1.9.14 when using the\nsudoers policy.\n\nOn systems that use PAM, the security policy's close function is responsible for closing  the\nPAM session.  It may also log the command's exit status.\n"
                    },
                    {
                        "name": "Signal handling",
                        "content": "When  the  command is run as a child of the sudo process, sudo will relay signals it receives\nto the command.  The SIGINT and SIGQUIT signals are only relayed when the  command  is  being\nrun  in  a  new pty or when the signal was sent by a user process, not the kernel.  This pre‐\nvents the command from receiving SIGINT twice each time the user enters control-C.  Some sig‐\nnals, such as SIGSTOP and SIGKILL, cannot be caught and thus  will  not  be  relayed  to  the\ncommand.   As a general rule, SIGTSTP should be used instead of SIGSTOP when you wish to sus‐\npend a command being run by sudo.\n\nAs a special case, sudo will not relay signals that were sent by the command it  is  running.\nThis  prevents  the command from accidentally killing itself.  On some systems, the reboot(8)\nutility sends SIGTERM to all non-system processes other than itself before rebooting the sys‐\ntem.  This prevents sudo from relaying the SIGTERM signal  it  received  back  to  reboot(8),\nwhich  might  then  exit  before  the system was actually rebooted, leaving it in a half-dead\nstate similar to single user mode.  Note, however,  that  this  check  only  applies  to  the\ncommand  run  by  sudo and not any other processes that the command may create.  As a result,\nrunning a script that calls reboot(8) or shutdown(8) via sudo may cause the system to end  up\nin  this  undefined state unless the reboot(8) or shutdown(8) are run using the exec() family\nof functions instead of system() (which interposes a shell between the command and the  call‐\ning process).\n"
                    },
                    {
                        "name": "Plugins",
                        "content": "Plugins  may be specified via Plugin directives in the sudo.conf(5) file.  They may be loaded\nas dynamic shared objects (on systems that support them), or compiled directly into the  sudo\nbinary.   If no sudo.conf(5) file is present, or if it doesn't contain any Plugin lines, sudo\nwill use sudoers(5) for the policy, auditing, and I/O logging plugins.  See the  sudo.conf(5)\nmanual for details of the /etc/sudo.conf file and the sudoplugin(5) manual for more informa‐\ntion about the sudo plugin architecture.\n"
                    }
                ]
            },
            "EXIT VALUE": {
                "content": "Upon  successful execution of a command, the exit status from sudo will be the exit status of\nthe program that was executed.  If the command terminated due to receipt of  a  signal,  sudo\nwill send itself the same signal that terminated the command.\n\nIf  the  -l  option  was specified without a command, sudo will exit with a value of 0 if the\nuser is allowed to run sudo and they authenticated successfully (as required by the  security\npolicy).   If a command is specified with the -l option, the exit value will only be 0 if the\ncommand is permitted by the security policy, otherwise it will be 1.\n\nIf there is an authentication failure, a configuration/permission problem, or  if  the  given\ncommand  cannot  be  executed,  sudo  exits with a value of 1.  In the latter case, the error\nstring is printed to the standard error.  If sudo cannot stat(2) one or more entries  in  the\nuser's  PATH, an error is printed to the standard error.  (If the directory does not exist or\nif it is not really a directory, the entry is ignored and no error is printed.)  This  should\nnot  happen  under  normal  circumstances.   The  most  common  reason  for stat(2) to return\n“permission denied” is if you are running an automounter and one of the directories  in  your\nPATH is on a machine that is currently unreachable.\n",
                "subsections": []
            },
            "SECURITY NOTES": {
                "content": "sudo tries to be safe when executing external commands.\n\nTo  prevent  command  spoofing, sudo checks \".\" and \"\" (both denoting current directory) last\nwhen searching for a command in the user's PATH (if one or both are in the PATH).   Depending\non  the  security  policy, the user's PATH environment variable may be modified, replaced, or\npassed unchanged to the program that sudo executes.\n\nUsers should never be granted sudo privileges to execute files that are writable by the  user\nor  that  reside  in a directory that is writable by the user.  If the user can modify or re‐\nplace the command there is no way to limit what additional commands they can run.\n\nBy default, sudo will only log the command it explicitly runs.  If a user runs a command such\nas ‘sudo su’ or ‘sudo sh’, subsequent commands run from that shell are not subject to  sudo's\nsecurity policy.  The same is true for commands that offer shell escapes (including most edi‐\ntors).   If  I/O  logging is enabled, subsequent commands will have their input and/or output\nlogged, but there will not be traditional logs for those commands. Because of this, care must\nbe taken when giving users access to commands via sudo to verify that the  command  does  not\ninadvertently  give  the  user  an  effective root shell.  For information on ways to address\nthis, see the Preventing shell escapes section in sudoers(5).\n\nTo prevent the disclosure of potentially sensitive information, sudo disables core  dumps  by\ndefault  while  it is executing (they are re-enabled for the command that is run).  This his‐\ntorical practice dates from a time when most operating systems allowed set-user-ID  processes\nto  dump  core  by default.  To aid in debugging sudo crashes, you may wish to re-enable core\ndumps by setting “disablecoredump” to false in the sudo.conf(5) file as follows:\n\nSet disablecoredump false\n\nSee the sudo.conf(5) manual for more information.\n",
                "subsections": []
            },
            "ENVIRONMENT": {
                "content": "sudo utilizes the following environment variables.  The security policy has control over  the\nactual content of the command's environment.\n\nEDITOR           Default  editor  to  use  in  -e  (sudoedit) mode if neither SUDOEDITOR nor\nVISUAL is set.\n\nMAIL             Set to the mail spool of the target user when the -i option is specified, or\nwhen envreset is enabled in sudoers (unless MAIL is present in the envkeep\nlist).\n\nHOME             Set to the home directory of the target user when the -i or -H  options  are\nspecified,  when  the -s option is specified and sethome is set in sudoers,\nwhen alwayssethome is enabled in sudoers, or when envreset is enabled  in\nsudoers and HOME is not present in the envkeep list.\n\nLOGNAME          Set  to  the  login name of the target user when the -i option is specified,\nwhen the setlogname option is enabled in sudoers, or when the envreset op‐\ntion is enabled in sudoers (unless LOGNAME is present in the envkeep list).\n\nPATH             May be overridden by the security policy.\n\nSHELL            Used to determine shell to run with -s option.\n\nSUDOASKPASS     Specifies the path to a helper program used to read the password if no  ter‐\nminal is available or if the -A option is specified.\n\nSUDOCOMMAND     Set  to  the command run by sudo, including any args. The args are truncated\nat 4096 characters to prevent a potential execution error.\n\nSUDOEDITOR      Default editor to use in -e (sudoedit) mode.\n\nSUDOGID         Set to the group-ID of the user who invoked sudo.\n\nSUDOPROMPT      Used as the default password prompt unless the -p option was specified.\n\nSUDOPS1         If set, PS1 will be set to its value for the program being run.\n\nSUDOUID         Set to the user-ID of the user who invoked sudo.\n\nSUDOUSER        Set to the login name of the user who invoked sudo.\n\nUSER             Set to the same value as LOGNAME, described above.\n\nVISUAL           Default editor to use in -e (sudoedit) mode if SUDOEDITOR is not set.\n",
                "subsections": []
            },
            "FILES": {
                "content": "/etc/sudo.conf            sudo front-end configuration\n",
                "subsections": []
            },
            "EXAMPLES": {
                "content": "The following examples assume a properly configured security policy.\n\nTo get a file listing of an unreadable directory:\n\n$ sudo ls /usr/local/protected\n\nTo list the home directory of user yaz on a machine where the file system holding ~yaz is not\nexported as root:\n\n$ sudo -u yaz ls ~yaz\n\nTo edit the index.html file as user www:\n\n$ sudoedit -u www ~www/htdocs/index.html\n\nTo view system logs only accessible to root and users in the adm group:\n\n$ sudo -g adm more /var/log/syslog\n\nTo run an editor as jim with a different primary group:\n\n$ sudoedit -u jim -g audio ~jim/sound.txt\n\nTo shut down a machine:\n\n$ sudo shutdown -r +15 \"quick reboot\"\n\nTo make a usage listing of the directories in the /home partition.  The commands are run in a\nsub-shell to allow the ‘cd’ command and file redirection to work.\n\n$ sudo sh -c \"cd /home ; du -s * | sort -rn > USAGE\"\n",
                "subsections": []
            },
            "DIAGNOSTICS": {
                "content": "Error messages produced by sudo include:\n",
                "subsections": [
                    {
                        "name": "editing files in a writable directory is not permitted",
                        "content": "By default, sudoedit does not permit editing a file when any of the parent  directories\nare  writable  by the invoking user.  This avoids a race condition that could allow the\nuser to overwrite an arbitrary file.  See the sudoeditcheckdir  option  in  sudoers(5)\nfor more information.\n"
                    },
                    {
                        "name": "editing symbolic links is not permitted",
                        "content": "By  default,  sudoedit  does  not  follow  symbolic  links when opening files.  See the\nsudoeditfollow option in sudoers(5) for more information.\n"
                    },
                    {
                        "name": "effective uid is not 0, is sudo installed setuid root?",
                        "content": "sudo was not run with root privileges.  The sudo binary must be owned by the root  user\nand  have  the  set-user-ID  bit  set.   Also,  it must not be located on a file system\nmounted with the ‘nosuid’ option or on an NFS file system that maps uid 0 to an unpriv‐\nileged uid.\n"
                    },
                    {
                        "name": "effective uid is not 0, is sudo on a file system with the 'nosuid' option set or an NFS  file",
                        "content": "system without root privileges?\nsudo  was  not run with root privileges.  The sudo binary has the proper owner and per‐\nmissions but it still did not run with root privileges.  The  most  common  reason  for\nthis is that the file system the sudo binary is located on is mounted with the ‘nosuid’\noption or it is an NFS file system that maps uid 0 to an unprivileged uid.\n"
                    },
                    {
                        "name": "fatal error, unable to load plugins",
                        "content": "An error occurred while loading or initializing the plugins specified in sudo.conf(5).\n"
                    },
                    {
                        "name": "invalid environment variable name",
                        "content": "One  or  more environment variable names specified via the -E option contained an equal\nsign (‘=’).  The arguments to the -E option should be environment variable names  with‐\nout an associated value.\n"
                    },
                    {
                        "name": "no password was provided",
                        "content": "When sudo tried to read the password, it did not receive any characters.  This may hap‐\npen  if no terminal is available (or the -S option is specified) and the standard input\nhas been redirected from /dev/null.\n"
                    },
                    {
                        "name": "a terminal is required to read the password",
                        "content": "sudo needs to read the password but there is no mechanism available for it to do so.  A\nterminal is not present to read the password from, sudo has not been configured to read\nfrom the standard input, the -S option was not used, and no  askpass  helper  has  been\nspecified either via the sudo.conf(5) file or the SUDOASKPASS environment variable.\n"
                    },
                    {
                        "name": "no writable temporary directory found",
                        "content": "sudoedit was unable to find a usable temporary directory in which to store its interme‐\ndiate files.\n\nThe “no new privileges” flag is set, which prevents sudo from running as root.\nsudo  was  run  by  a process that has the Linux “no new privileges” flag is set.  This\ncauses the set-user-ID bit to be ignored when running an executable, which will prevent\nsudo from functioning.  The most likely cause for this is running sudo  within  a  con‐\ntainer  that  sets this flag.  Check the documentation to see if it is possible to con‐\nfigure the container such that the flag is not set.\n"
                    },
                    {
                        "name": "sudo must be owned by uid 0 and have the setuid bit set",
                        "content": "sudo was not run with root privileges.  The sudo binary does not have the correct owner\nor permissions.  It must be owned by the root user and have the set-user-ID bit set.\n"
                    },
                    {
                        "name": "sudoedit is not supported on this platform",
                        "content": "It is only possible to run sudoedit on systems that support setting the effective user-\nID.\n"
                    },
                    {
                        "name": "timed out reading password",
                        "content": "The user did not enter a password before the password timeout (5  minutes  by  default)\nexpired.\n"
                    },
                    {
                        "name": "you do not exist in the passwd database",
                        "content": "Your user-ID does not appear in the system passwd database.\n"
                    },
                    {
                        "name": "you may not specify environment variables in edit mode",
                        "content": "It  is  only  possible  to  specify environment variables when running a command.  When\nediting a file, the editor is run with the user's environment unmodified.\n"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "su(1),  stat(2),   logincap(3),   passwd(5),   sudo.conf(5),   sudoplugin(5),   sudoers(5),\nsudoerstimestamp(5), sudoreplay(8), visudo(8)\n",
                "subsections": []
            },
            "HISTORY": {
                "content": "See  the  HISTORY.md file in the sudo distribution (https://www.sudo.ws/about/history/) for a\nbrief history of sudo.\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "Many people have worked on sudo over the years; this version consists of code written primar‐\nily by:\n\nTodd C. Miller\n\nSee the CONTRIBUTORS.md file in the  sudo  distribution  (https://www.sudo.ws/about/contribu‐\ntors/) for an exhaustive list of people who have contributed to sudo.\n",
                "subsections": []
            },
            "CAVEATS": {
                "content": "There  is  no easy way to prevent a user from gaining a root shell if that user is allowed to\nrun arbitrary commands via sudo.  Also, many programs (such as editors) allow the user to run\ncommands via shell escapes, thus avoiding sudo's checks.  However, on most systems it is pos‐\nsible to prevent shell escapes with the sudoers(5) plugin's noexec functionality.\n\nIt is not meaningful to run the ‘cd’ command directly via sudo, e.g.,\n\n$ sudo cd /usr/local/protected\n\nsince when the command exits the parent process (your shell) will still be the same.  The  -D\noption can be used to run a command in a specific directory.\n\nRunning  shell  scripts  via sudo can expose the same kernel bugs that make set-user-ID shell\nscripts unsafe on some operating systems (if your OS has a  /dev/fd/  directory,  set-user-ID\nshell scripts are generally safe).\n",
                "subsections": []
            },
            "BUGS": {
                "content": "If   you   believe  you  have  found  a  bug  in  sudo,  you  can  submit  a  bug  report  at\nhttps://bugzilla.sudo.ws/\n",
                "subsections": []
            },
            "SUPPORT": {
                "content": "Limited   free   support   is   available   via   the   sudo-users    mailing    list,    see\nhttps://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search the archives.\n",
                "subsections": []
            },
            "DISCLAIMER": {
                "content": "sudo  is  provided  “AS IS” and any express or implied warranties, including, but not limited\nto, the implied warranties of merchantability and fitness for a particular purpose  are  dis‐\nclaimed.  See the LICENSE.md file distributed with sudo or https://www.sudo.ws/about/license/\nfor complete details.\n\nSudo 1.9.15p5                              August 9, 2023                                    SUDO(8)",
                "subsections": []
            }
        }
    }
}