{
    "mode": "man",
    "parameter": "setpriv",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/setpriv/1/json",
    "generated": "2026-08-26T02:10:23Z",
    "synopsis": "setpriv [options] program [arguments]",
    "sections": {
        "NAME": {
            "content": "setpriv - run a program with different Linux privilege settings\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "setpriv [options] program [arguments]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Sets or queries various Linux privilege settings that are inherited across execve(2).\n\nIn comparison to su(1) and runuser(1), setpriv neither uses PAM, nor does it prompt for a\npassword. It is a simple, non-set-user-ID wrapper around execve(2), and can be used to drop\nprivileges in the same way as setuidgid(8) from daemontools, chpst(8) from runit, or similar\ntools shipped by other service managers.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "--clear-groups",
                    "content": "Clear supplementary groups.\n",
                    "long": "--clear-groups"
                },
                {
                    "name": "-d --dump",
                    "content": "Dump the current privilege state. This option can be specified more than once to show\nextra, mostly useless, information. Incompatible with all other options.\n\n--groups group...\nSet supplementary groups. The argument is a comma-separated list of GIDs or names.\n\n--inh-caps (+|-)cap..., --ambient-caps (+|-)cap..., --bounding-set (+|-)cap...\nSet the inheritable capabilities, ambient capabilities or the capability bounding set.\nSee capabilities(7). The argument is a comma-separated list of +cap and -cap entries,\nwhich add or remove an entry respectively. cap can either be a human-readable name as\nseen in capabilities(7) without the cap prefix or of the format capN, where N is the\ninternal capability index used by Linux. +all and -all can be used to add or remove all\ncaps.\n\nThe set of capabilities starts out as the current inheritable set for --inh-caps, the\ncurrent ambient set for --ambient-caps and the current bounding set for --bounding-set.\n\nNote the following restrictions (detailed in capabilities(7)) regarding modifications to\nthese capability sets:\n\n•   A capability can be added to the inheritable set only if it is currently present in\nthe bounding set.\n\n•   A capability can be added to the ambient set only if it is currently present in both\nthe permitted and inheritable sets.\n\n•   Notwithstanding the syntax offered by setpriv, the kernel does not permit\ncapabilities to be added to the bounding set.\n\nIf you drop a capability from the bounding set without also dropping it from the inheritable\nset, you are likely to become confused. Do not do that.\n",
                    "flag": "-d",
                    "long": "--dump"
                },
                {
                    "name": "--keep-groups",
                    "content": "Preserve supplementary groups. Only useful in conjunction with --rgid, --egid, or\n--regid.\n",
                    "long": "--keep-groups"
                },
                {
                    "name": "--init-groups",
                    "content": "Initialize supplementary groups using initgroups3. Only useful in conjunction with --ruid\nor --reuid.\n",
                    "long": "--init-groups"
                },
                {
                    "name": "--list-caps",
                    "content": "List all known capabilities. This option must be specified alone.\n",
                    "long": "--list-caps"
                },
                {
                    "name": "--no-new-privs",
                    "content": "Set the nonewprivs bit. With this bit set, execve(2) will not grant new privileges. For\nexample, the set-user-ID and set-group-ID bits as well as file capabilities will be\ndisabled. (Executing binaries with these bits set will still work, but they will not gain\nprivileges. Certain LSMs, especially AppArmor, may result in failures to execute certain\nprograms.) This bit is inherited by child processes and cannot be unset. See prctl(2) and\nDocumentation/prctl/nonewprivs.txt in the Linux kernel source.\n\nThe nonewprivs bit is supported since Linux 3.5.\n\n--rgid gid, --egid gid, --regid gid\nSet the real, effective, or both GIDs. The gid argument can be given as a textual group\nname.\n\nFor safety, you must specify one of --clear-groups, --groups, --keep-groups, or\n--init-groups if you set any primary gid.\n\n--ruid uid, --euid uid, --reuid uid\nSet the real, effective, or both UIDs. The uid argument can be given as a textual login\nname.\n\nSetting a uid or gid does not change capabilities, although the exec call at the end\nmight change capabilities. This means that, if you are root, you probably want to do\nsomething like:\n\nsetpriv --reuid=1000 --regid=1000 --inh-caps=-all\n\n--securebits (+|-)securebit...\nSet or clear securebits. The argument is a comma-separated list. The valid securebits are\nnoroot, norootlocked, nosetuidfixup, nosetuidfixuplocked, and keepcapslocked.\nkeepcaps is cleared by execve(2) and is therefore not allowed.\n\n--pdeathsig keep|clear|<signal>\nKeep, clear or set the parent death signal. Some LSMs, most notably SELinux and AppArmor,\nclear the signal when the process' credentials change. Using --pdeathsig keep will\nrestore the parent death signal after changing credentials to remedy that situation.\n\n--selinux-label label\nRequest a particular SELinux transition (using a transition on exec, not dyntrans). This\nwill fail and cause setpriv to abort if SELinux is not in use, and the transition may be\nignored or cause execve(2) to fail at SELinux’s whim. (In particular, this is unlikely to\nwork in conjunction with nonewprivs.) This is similar to runcon(1).\n\n--apparmor-profile profile\nRequest a particular AppArmor profile (using a transition on exec). This will fail and\ncause setpriv to abort if AppArmor is not in use, and the transition may be ignored or\ncause execve(2) to fail at AppArmor’s whim.\n",
                    "long": "--no-new-privs"
                },
                {
                    "name": "--reset-env",
                    "content": "Clears all the environment variables except TERM; initializes the environment variables\nHOME, SHELL, USER, LOGNAME according to the user’s passwd entry; sets PATH to\n/usr/local/bin:/bin:/usr/bin for a regular user and to\n/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin for root.\n\nThe environment variable PATH may be different on systems where /bin and /sbin are merged\ninto /usr. The environment variable SHELL defaults to /bin/sh if none is given in the\nuser’s passwd entry.\n",
                    "long": "--reset-env"
                },
                {
                    "name": "-h --help",
                    "content": "Display help text and exit.\n",
                    "flag": "-h",
                    "long": "--help"
                },
                {
                    "name": "-V --version",
                    "content": "Print version and exit.\n",
                    "flag": "-V",
                    "long": "--version"
                }
            ]
        },
        "NOTES": {
            "content": "If applying any specified option fails, program will not be run and setpriv will return with\nexit status 127.\n\nBe careful with this tool — it may have unexpected security consequences. For example,\nsetting nonewprivs and then execing a program that is SELinux-confined (as this tool would\ndo) may prevent the SELinux restrictions from taking effect.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "If you’re looking for behavior similar to su(1)/runuser(1), or sudo(8) (without the -g\noption), try something like:\n",
            "subsections": [
                {
                    "name": "setpriv --reuid=1000 --regid=1000 --init-groups",
                    "content": "If you want to mimic daemontools' setuid(8), try:\n"
                },
                {
                    "name": "setpriv --reuid=1000 --regid=1000 --clear-groups",
                    "content": ""
                }
            ]
        },
        "AUTHORS": {
            "content": "\u001b[34mAndy Lutomirski \u001b[0m<luto@amacapital.net>\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "runuser(1), su(1), prctl(2), capabilities(7)\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "For bug reports, use the issue tracker at \u001b[34mhttps://github.com/util-linux/util-linux/issues\u001b[0m.\n",
            "subsections": []
        },
        "AVAILABILITY": {
            "content": "The setpriv command is part of the util-linux package which can be downloaded from \u001b[34mLinux\u001b[0m\n\u001b[34mKernel Archive \u001b[0m<https://www.kernel.org/pub/linux/utils/util-linux/>.\n\nutil-linux 2.39.3                            2023-10-23                                   SETPRIV(1)",
            "subsections": []
        }
    },
    "summary": "setpriv - run a program with different Linux privilege settings",
    "flags": [
        {
            "flag": "",
            "long": "--clear-groups",
            "arg": null,
            "description": "Clear supplementary groups."
        },
        {
            "flag": "-d",
            "long": "--dump",
            "arg": null,
            "description": "Dump the current privilege state. This option can be specified more than once to show extra, mostly useless, information. Incompatible with all other options. --groups group... Set supplementary groups. The argument is a comma-separated list of GIDs or names. --inh-caps (+|-)cap..., --ambient-caps (+|-)cap..., --bounding-set (+|-)cap... Set the inheritable capabilities, ambient capabilities or the capability bounding set. See capabilities(7). The argument is a comma-separated list of +cap and -cap entries, which add or remove an entry respectively. cap can either be a human-readable name as seen in capabilities(7) without the cap prefix or of the format capN, where N is the internal capability index used by Linux. +all and -all can be used to add or remove all caps. The set of capabilities starts out as the current inheritable set for --inh-caps, the current ambient set for --ambient-caps and the current bounding set for --bounding-set. Note the following restrictions (detailed in capabilities(7)) regarding modifications to these capability sets: • A capability can be added to the inheritable set only if it is currently present in the bounding set. • A capability can be added to the ambient set only if it is currently present in both the permitted and inheritable sets. • Notwithstanding the syntax offered by setpriv, the kernel does not permit capabilities to be added to the bounding set. If you drop a capability from the bounding set without also dropping it from the inheritable set, you are likely to become confused. Do not do that."
        },
        {
            "flag": "",
            "long": "--keep-groups",
            "arg": null,
            "description": "Preserve supplementary groups. Only useful in conjunction with --rgid, --egid, or --regid."
        },
        {
            "flag": "",
            "long": "--init-groups",
            "arg": null,
            "description": "Initialize supplementary groups using initgroups3. Only useful in conjunction with --ruid or --reuid."
        },
        {
            "flag": "",
            "long": "--list-caps",
            "arg": null,
            "description": "List all known capabilities. This option must be specified alone."
        },
        {
            "flag": "",
            "long": "--no-new-privs",
            "arg": null,
            "description": "Set the nonewprivs bit. With this bit set, execve(2) will not grant new privileges. For example, the set-user-ID and set-group-ID bits as well as file capabilities will be disabled. (Executing binaries with these bits set will still work, but they will not gain privileges. Certain LSMs, especially AppArmor, may result in failures to execute certain programs.) This bit is inherited by child processes and cannot be unset. See prctl(2) and Documentation/prctl/nonewprivs.txt in the Linux kernel source. The nonewprivs bit is supported since Linux 3.5. --rgid gid, --egid gid, --regid gid Set the real, effective, or both GIDs. The gid argument can be given as a textual group name. For safety, you must specify one of --clear-groups, --groups, --keep-groups, or --init-groups if you set any primary gid. --ruid uid, --euid uid, --reuid uid Set the real, effective, or both UIDs. The uid argument can be given as a textual login name. Setting a uid or gid does not change capabilities, although the exec call at the end might change capabilities. This means that, if you are root, you probably want to do something like: setpriv --reuid=1000 --regid=1000 --inh-caps=-all --securebits (+|-)securebit... Set or clear securebits. The argument is a comma-separated list. The valid securebits are noroot, norootlocked, nosetuidfixup, nosetuidfixuplocked, and keepcapslocked. keepcaps is cleared by execve(2) and is therefore not allowed. --pdeathsig keep|clear|<signal> Keep, clear or set the parent death signal. Some LSMs, most notably SELinux and AppArmor, clear the signal when the process' credentials change. Using --pdeathsig keep will restore the parent death signal after changing credentials to remedy that situation. --selinux-label label Request a particular SELinux transition (using a transition on exec, not dyntrans). This will fail and cause setpriv to abort if SELinux is not in use, and the transition may be ignored or cause execve(2) to fail at SELinux’s whim. (In particular, this is unlikely to work in conjunction with nonewprivs.) This is similar to runcon(1). --apparmor-profile profile Request a particular AppArmor profile (using a transition on exec). This will fail and cause setpriv to abort if AppArmor is not in use, and the transition may be ignored or cause execve(2) to fail at AppArmor’s whim."
        },
        {
            "flag": "",
            "long": "--reset-env",
            "arg": null,
            "description": "Clears all the environment variables except TERM; initializes the environment variables HOME, SHELL, USER, LOGNAME according to the user’s passwd entry; sets PATH to /usr/local/bin:/bin:/usr/bin for a regular user and to /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin for root. The environment variable PATH may be different on systems where /bin and /sbin are merged into /usr. The environment variable SHELL defaults to /bin/sh if none is given in the user’s passwd entry."
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "Display help text and exit."
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "Print version and exit."
        }
    ],
    "examples": [
        "If you’re looking for behavior similar to su(1)/runuser(1), or sudo(8) (without the -g",
        "option), try something like:",
        "If you want to mimic daemontools' setuid(8), try:"
    ],
    "see_also": [
        {
            "name": "runuser",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/runuser/1/json"
        },
        {
            "name": "su",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/su/1/json"
        },
        {
            "name": "prctl",
            "section": "2",
            "url": "https://www.chedong.com/phpMan.php/man/prctl/2/json"
        },
        {
            "name": "capabilities",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/capabilities/7/json"
        }
    ]
}