{
    "content": [
        {
            "type": "text",
            "text": "# SU (man)\n\n## NAME\n\nsu - run a command with substitute user and group ID\n\n## SYNOPSIS\n\nsu [options] [-] [user [argument...]]\n\n## DESCRIPTION\n\nsu allows commands to be run with a substitute user and group ID.\n\n## TLDR\n\n> Switch shell to another user.\n\n- Switch to superuser (requires the root password):\n  `su`\n- Switch to a given user (requires the user's password):\n  `su {{username}}`\n- Switch to a given user and simulate a full login shell:\n  `su - {{username}}`\n- Execute a command as another user:\n  `su - {{username}} {{-c|--command}} \"{{command}}\"`\n- Switch to a given user and use a specific shell (e.g., Zsh, fish, Bash):\n  `su {{-s|--shell}} /{{path/to/shell}} {{username}}`\n- Display help:\n  `su {{-h|--help}}`\n- Display version:\n  `su {{-V|--version}}`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS** (10 subsections)\n- **SIGNALS**\n- **CONFIG FILES** (4 subsections)\n- **EXIT STATUS**\n- **FILES**\n- **NOTES**\n- **HISTORY**\n- **SEE ALSO**\n- **REPORTING BUGS**\n- **AVAILABILITY**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "SU",
        "section": "",
        "mode": "man",
        "summary": "su - run a command with substitute user and group ID",
        "synopsis": "su [options] [-] [user [argument...]]",
        "tldr_summary": "Switch shell to another user.",
        "tldr_examples": [
            {
                "description": "Switch to superuser (requires the root password)",
                "command": "su"
            },
            {
                "description": "Switch to a given user (requires the user's password)",
                "command": "su {{username}}"
            },
            {
                "description": "Switch to a given user and simulate a full login shell",
                "command": "su - {{username}}"
            },
            {
                "description": "Execute a command as another user",
                "command": "su - {{username}} {{-c|--command}} \"{{command}}\""
            },
            {
                "description": "Switch to a given user and use a specific shell (e.g., Zsh, fish, Bash)",
                "command": "su {{-s|--shell}} /{{path/to/shell}} {{username}}"
            },
            {
                "description": "Display help",
                "command": "su {{-h|--help}}"
            },
            {
                "description": "Display version",
                "command": "su {{-V|--version}}"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "-c",
                "long": "--command",
                "arg": null,
                "description": "Pass command to the shell with the -c option."
            },
            {
                "flag": "-f",
                "long": "--fast",
                "arg": null,
                "description": "Pass -f to the shell, which may or may not be useful, depending on the shell."
            },
            {
                "flag": "-g",
                "long": "--group",
                "arg": null,
                "description": "Specify the primary group. This option is available to the root user only."
            },
            {
                "flag": "-G",
                "long": "--supp-group",
                "arg": null,
                "description": "Specify a supplementary group. This option is available to the root user only. The first specified supplementary group is also used as a primary group if the option --group is not specified. -, -l, --login Start the shell as a login shell with an environment similar to a real login: • clears all the environment variables except TERM and variables specified by --whitelist-environment • initializes the environment variables HOME, SHELL, USER, LOGNAME, and PATH • changes to the target user’s home directory • sets argv[0] of the shell to '-' in order to make the shell a login shell"
            },
            {
                "flag": "-p",
                "long": "--preserve-environment",
                "arg": null,
                "description": "Preserve the entire environment, i.e., do not set HOME, SHELL, USER or LOGNAME. This option is ignored if the option --login is specified."
            },
            {
                "flag": "-P",
                "long": "--pty",
                "arg": null,
                "description": "Create a pseudo-terminal for the session. The independent terminal provides better security as the user does not share a terminal with the original session. This can be used to avoid TIOCSTI ioctl terminal injection and other security attacks against terminal file descriptors. The entire session can also be moved to the background (e.g., \"su --pty - username -c application &\"). If the pseudo-terminal is enabled, then su works as a proxy between the sessions (copy stdin and stdout). This feature is mostly designed for interactive sessions. If the standard input is not a terminal, but for example a pipe (e.g., echo \"date\" | su --pty), then the ECHO flag for the pseudo-terminal is disabled to avoid messy output."
            },
            {
                "flag": "-s",
                "long": "--shell",
                "arg": null,
                "description": "Run the specified shell instead of the default. The shell to run is selected according to the following rules, in order: • the shell specified with --shell • the shell specified in the environment variable SHELL, if the --preserve-environment option is used • the shell listed in the passwd entry of the target user • /bin/sh If the target user has a restricted shell (i.e., not listed in /etc/shells), the --shell option and the SHELL environment variables are ignored unless the calling user is root. --session-command=command Same as -c, but do not create a new session. (Discouraged.)"
            },
            {
                "flag": "-w",
                "long": "--whitelist-environment",
                "arg": null,
                "description": "Don’t reset the environment variables specified in the comma-separated list when clearing the environment for --login. The whitelist is ignored for the environment variables HOME, SHELL, USER, LOGNAME, and PATH."
            },
            {
                "flag": "-V",
                "long": "--version",
                "arg": null,
                "description": "Display version information and exit."
            },
            {
                "flag": "-h",
                "long": "--help",
                "arg": null,
                "description": "Display help text and exit."
            }
        ],
        "examples": [],
        "see_also": [
            {
                "name": "setpriv",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/setpriv/1/json"
            },
            {
                "name": "login.defs",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/login.defs/5/json"
            },
            {
                "name": "shells",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/shells/5/json"
            },
            {
                "name": "pam",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/pam/8/json"
            },
            {
                "name": "runuser",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/runuser/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 24,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "-c --command",
                        "lines": 2,
                        "flag": "-c",
                        "long": "--command"
                    },
                    {
                        "name": "-f --fast",
                        "lines": 2,
                        "flag": "-f",
                        "long": "--fast"
                    },
                    {
                        "name": "-g --group",
                        "lines": 2,
                        "flag": "-g",
                        "long": "--group"
                    },
                    {
                        "name": "-G --supp-group",
                        "lines": 16,
                        "flag": "-G",
                        "long": "--supp-group"
                    },
                    {
                        "name": "-m -p --preserve-environment",
                        "lines": 3,
                        "flag": "-p",
                        "long": "--preserve-environment"
                    },
                    {
                        "name": "-P --pty",
                        "lines": 11,
                        "flag": "-P",
                        "long": "--pty"
                    },
                    {
                        "name": "-s --shell",
                        "lines": 18,
                        "flag": "-s",
                        "long": "--shell"
                    },
                    {
                        "name": "-w --whitelist-environment",
                        "lines": 4,
                        "flag": "-w",
                        "long": "--whitelist-environment"
                    },
                    {
                        "name": "-V --version",
                        "lines": 2,
                        "flag": "-V",
                        "long": "--version"
                    },
                    {
                        "name": "-h --help",
                        "lines": 2,
                        "flag": "-h",
                        "long": "--help"
                    }
                ]
            },
            {
                "name": "SIGNALS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "CONFIG FILES",
                "lines": 3,
                "subsections": [
                    {
                        "name": "FAIL___DELAY (number)",
                        "lines": 3
                    },
                    {
                        "name": "ENV___PATH (string)",
                        "lines": 3
                    },
                    {
                        "name": "ENV___ROOTPATH (string), ENV___SUPATH (string)",
                        "lines": 3
                    },
                    {
                        "name": "ALWAYS___SET___PATH (boolean)",
                        "lines": 7
                    }
                ]
            },
            {
                "name": "EXIT STATUS",
                "lines": 14,
                "subsections": []
            },
            {
                "name": "FILES",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "HISTORY",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "REPORTING BUGS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AVAILABILITY",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "su - run a command with substitute user and group ID\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "su [options] [-] [user [argument...]]\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "su allows commands to be run with a substitute user and group ID.\n\nWhen called with no user specified, su defaults to running an interactive shell as root. When\nuser is specified, additional arguments can be supplied, in which case they are passed to the\nshell.\n\nFor backward compatibility, su defaults to not change the current directory and to only set\nthe environment variables HOME and SHELL (plus USER and LOGNAME if the target user is not\nroot). It is recommended to always use the --login option (instead of its shortcut -) to\navoid side effects caused by mixing environments.\n\nThis version of su uses PAM for authentication, account and session management. Some\nconfiguration options found in other su implementations, such as support for a wheel group,\nhave to be configured via PAM.\n\nsu is mostly designed for unprivileged users, the recommended solution for privileged users\n(e.g., scripts executed by root) is to use non-set-user-ID command runuser(1) that does not\nrequire authentication and provides separate PAM configuration. If the PAM session is not\nrequired at all then the recommended solution is to use command setpriv(1).\n\nNote that su in all cases uses PAM (pamgetenvlist(3)) to do the final environment\nmodification. Command-line options such as --login and --preserve-environment affect the\nenvironment before it is modified by PAM.\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "",
                "subsections": [
                    {
                        "name": "-c --command",
                        "content": "Pass command to the shell with the -c option.\n",
                        "flag": "-c",
                        "long": "--command"
                    },
                    {
                        "name": "-f --fast",
                        "content": "Pass -f to the shell, which may or may not be useful, depending on the shell.\n",
                        "flag": "-f",
                        "long": "--fast"
                    },
                    {
                        "name": "-g --group",
                        "content": "Specify the primary group. This option is available to the root user only.\n",
                        "flag": "-g",
                        "long": "--group"
                    },
                    {
                        "name": "-G --supp-group",
                        "content": "Specify a supplementary group. This option is available to the root user only. The first\nspecified supplementary group is also used as a primary group if the option --group is\nnot specified.\n\n-, -l, --login\nStart the shell as a login shell with an environment similar to a real login:\n\n•   clears all the environment variables except TERM and variables specified by\n--whitelist-environment\n\n•   initializes the environment variables HOME, SHELL, USER, LOGNAME, and PATH\n\n•   changes to the target user’s home directory\n\n•   sets argv[0] of the shell to '-' in order to make the shell a login shell\n",
                        "flag": "-G",
                        "long": "--supp-group"
                    },
                    {
                        "name": "-m -p --preserve-environment",
                        "content": "Preserve the entire environment, i.e., do not set HOME, SHELL, USER or LOGNAME. This\noption is ignored if the option --login is specified.\n",
                        "flag": "-p",
                        "long": "--preserve-environment"
                    },
                    {
                        "name": "-P --pty",
                        "content": "Create a pseudo-terminal for the session. The independent terminal provides better\nsecurity as the user does not share a terminal with the original session. This can be\nused to avoid TIOCSTI ioctl terminal injection and other security attacks against\nterminal file descriptors. The entire session can also be moved to the background (e.g.,\n\"su --pty - username -c application &\"). If the pseudo-terminal is enabled, then su works\nas a proxy between the sessions (copy stdin and stdout).\n\nThis feature is mostly designed for interactive sessions. If the standard input is not a\nterminal, but for example a pipe (e.g., echo \"date\" | su --pty), then the ECHO flag for\nthe pseudo-terminal is disabled to avoid messy output.\n",
                        "flag": "-P",
                        "long": "--pty"
                    },
                    {
                        "name": "-s --shell",
                        "content": "Run the specified shell instead of the default. The shell to run is selected according to\nthe following rules, in order:\n\n•   the shell specified with --shell\n\n•   the shell specified in the environment variable SHELL, if the --preserve-environment\noption is used\n\n•   the shell listed in the passwd entry of the target user\n\n•   /bin/sh\n\nIf the target user has a restricted shell (i.e., not listed in /etc/shells), the --shell\noption and the SHELL environment variables are ignored unless the calling user is root.\n\n--session-command=command\nSame as -c, but do not create a new session. (Discouraged.)\n",
                        "flag": "-s",
                        "long": "--shell"
                    },
                    {
                        "name": "-w --whitelist-environment",
                        "content": "Don’t reset the environment variables specified in the comma-separated list when clearing\nthe environment for --login. The whitelist is ignored for the environment variables HOME,\nSHELL, USER, LOGNAME, and PATH.\n",
                        "flag": "-w",
                        "long": "--whitelist-environment"
                    },
                    {
                        "name": "-V --version",
                        "content": "Display version information and exit.\n",
                        "flag": "-V",
                        "long": "--version"
                    },
                    {
                        "name": "-h --help",
                        "content": "Display help text and exit.\n",
                        "flag": "-h",
                        "long": "--help"
                    }
                ]
            },
            "SIGNALS": {
                "content": "Upon receiving either SIGINT, SIGQUIT or SIGTERM, su terminates its child and afterwards\nterminates itself with the received signal. The child is terminated by SIGTERM, after\nunsuccessful attempt and 2 seconds of delay the child is killed by SIGKILL.\n",
                "subsections": []
            },
            "CONFIG FILES": {
                "content": "su reads the /etc/default/su and /etc/login.defs configuration files. The following\nconfiguration items are relevant for su:\n",
                "subsections": [
                    {
                        "name": "FAIL___DELAY (number)",
                        "content": "Delay in seconds in case of an authentication failure. The number must be a non-negative\ninteger.\n"
                    },
                    {
                        "name": "ENV___PATH (string)",
                        "content": "Defines the PATH environment variable for a regular user. The default value is\n/usr/local/bin:/bin:/usr/bin.\n"
                    },
                    {
                        "name": "ENV___ROOTPATH (string), ENV___SUPATH (string)",
                        "content": "Defines the PATH environment variable for root. ENVSUPATH takes precedence. The default\nvalue is /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin.\n"
                    },
                    {
                        "name": "ALWAYS___SET___PATH (boolean)",
                        "content": "If set to yes and --login and --preserve-environment were not specified su initializes\nPATH.\n\nThe environment variable PATH may be different on systems where /bin and /sbin are merged\ninto /usr; this variable is also affected by the --login command-line option and the PAM\nsystem setting (e.g., pamenv(8)).\n"
                    }
                ]
            },
            "EXIT STATUS": {
                "content": "su normally returns the exit status of the command it executed. If the command was killed by\na signal, su returns the number of the signal plus 128.\n\nExit status generated by su itself:\n\n1\nGeneric error before executing the requested command\n\n126\nThe requested command could not be executed\n\n127\nThe requested command was not found\n",
                "subsections": []
            },
            "FILES": {
                "content": "/etc/pam.d/su\ndefault PAM configuration file\n\n/etc/pam.d/su-l\nPAM configuration file if --login is specified\n\n/etc/default/su\ncommand specific logindef config file\n\n/etc/login.defs\nglobal logindef config file\n",
                "subsections": []
            },
            "NOTES": {
                "content": "For security reasons, su always logs failed log-in attempts to the btmp file, but it does not\nwrite to the lastlog file at all. This solution can be used to control su behavior by PAM\nconfiguration. If you want to use the pamlastlog(8) module to print warning message about\nfailed log-in attempts then pamlastlog(8) has to be configured to update the lastlog file as\nwell. For example by:\n\nsession required pamlastlog.so nowtmp\n",
                "subsections": []
            },
            "HISTORY": {
                "content": "This su command was derived from coreutils' su, which was based on an implementation by David\nMacKenzie. The util-linux version has been refactored by Karel Zak.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "setpriv(1), login.defs(5), shells(5), pam(8), runuser(1)\n",
                "subsections": []
            },
            "REPORTING BUGS": {
                "content": "For bug reports, use the issue tracker at https://github.com/karelzak/util-linux/issues.\n",
                "subsections": []
            },
            "AVAILABILITY": {
                "content": "The su command is part of the util-linux package which can be downloaded from Linux Kernel\nArchive <https://www.kernel.org/pub/linux/utils/util-linux/>.\n\n\n\nutil-linux 2.37.2                            2021-06-02                                        SU(1)",
                "subsections": []
            }
        }
    }
}