SETPRIV(1)
๐ SETPRIV(1) ๐
okay bestie, welcome to setpriv, a User Commands girlie from the util-linux family โจ she's the one who runs a program with different Linux privilege settings, and she does it with zero drama and zero password prompts ๐
๐ธ NAME ๐ธ
setpriv โ run a program with different Linux privilege settings ๐ฆ
โจ SYNOPSIS โจ
setpriv [options] program [arguments]
๐ DESCRIPTION ๐
So what she does is: she sets or queries various Linux privilege settings that get inherited across execve(2) ๐
Now, compared to su(1) and runuser(1), our girl setpriv neither uses PAM nor prompts for a password. Not once. Not ever. She is a simple, non-set-user-ID wrapper around execve(2), and you can use her to drop privileges in exactly the same way as setuidgid(8) from daemontools, chpst(8) from runit, or whatever similar tools those other service managers ship ๐
๐ OPTIONS ๐
--clear-groupsโ Clear supplementary groups. bye bestie ๐-d,--dumpโ Dump the current privilege state. You can specify this option more than once to show extra, mostly useless, information. Incompatible with all other options ๐ซ (yes, she said what she said)--groupsgroup... โ 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. Seecapabilities(7). The argument is a comma-separated list of+capand-capentries, which add or remove an entry respectively.capcan either be a human-readable name as seen incapabilities(7)without thecap_prefix or of the formatcap_N, where N is the internal capability index used by Linux.+alland-allcan 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. fr fr, do NOT do that ๐ญ
--keep-groupsโ Preserve supplementary groups. Only useful in conjunction with--rgid,--egid, or--regid.--init-groupsโ Initialize supplementary groups usinginitgroups3. Only useful in conjunction with--ruidor--reuid.--list-capsโ List all known capabilities. This option must be specified alone, she's a solo act ๐--nnp,--no-new-privsโ Set theno_new_privsbit. 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. Seeprctl(2)andDocumentation/prctl/no_new_privs.txtin the Linux kernel source.
The no_new_privs bit is supported since Linux 3.5.
--rgidgid,--egidgid,--regidgid โ 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 ๐ซถ
--ruiduid,--euiduid,--reuiduid โ 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 arenoroot,noroot_locked,no_setuid_fixup,no_setuid_fixup_locked, andkeep_caps_locked.keep_capsis cleared byexecve(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 keepwill restore the parent death signal after changing credentials to remedy that situation.--ptracer pid|any|noneโ When Yama's restricted ptrace mode is in effect (that is, when/proc/sys/kernel/yama/ptrace_scopeis set to1), allow being traced viaptrace(2)by the process with the specified PID, or any process, or no process. SeePR_SET_PTRACER(2const). (Note that this is not inherited by child processes, though it is preserved acrossexecve(2).) This option has no effect when Yama is not enabled or is in a mode other than restricted ptrace.--selinux-labellabel โ Request a particular SELinux transition (using a transition on exec, not dyntrans). This will fail and causesetprivto abort if SELinux is not in use, and the transition may be ignored or causeexecve(2)to fail at SELinux's whim. (In particular, this is unlikely to work in conjunction withno_new_privs.) This is similar toruncon(1).--apparmor-profileprofile โ Request a particular AppArmor profile (using a transition on exec). This will fail and causesetprivto abort if AppArmor is not in use, and the transition may be ignored or causeexecve(2)to fail at AppArmor's whim ๐--landlock-accessaccess โ Enable landlock restrictions for a specific set of system accesses. To allow specific subgroups of accesses use--landlock-rule.
Block all filesystem access:
setpriv --landlock-access fs
Block all file deletions and directory creations:
setpriv --landlock-access fs:remove-file,make-dir
For a complete set of supported access categories use setpriv --help.
The generic placeholder "fs" is subject to change and may be extended in future versions to support new access types โญ
--landlock-rulerule โ Allow one specific access from the categories blocked by--landlock-access.
The syntax is as follows:
--landlock-rule $ruletype:$access:$rulearg
For example grant file read access to everything under /boot:
--landlock-rule path-beneath:read-file:/boot
--seccomp-filterfile โ Load raw BPF seccomp filter code from a file.
Filters can for example be created with enosys ๐
--reset-env- clears all the environment variables except
TERMenvironment variable - initializes the environment variables
HOME,SHELL,USER,LOGNAMEaccording to the user's passwd entry - the environment variable
SHELLdefaults to/bin/shif none is given in the user's passwd entry. - resets
PATHenvironment variable according to setting in/etc/login.defs(ENV_PATH,ENV_SUPATHorENV_ROOTPATHvariables), or defaults to/usr/local/bin:/bin:/usr/binfor a regular user and to/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binfor root.
- clears all the environment variables except
The environment variable PATH may be different on systems where /bin and /sbin are merged into /usr.
-h,--helpโ Display help text and exit. ๐ซถ-V,--versionโ Display version and exit. ๐
๐ NOTES ๐
If applying any specified option fails, program will not be run and setpriv will return with exit status 127 ๐ญ
Be careful with this tool โ it may have unexpected security consequences. For example, setting no_new_privs and then execing a program that is SELinux-confined (as this tool would do) may prevent the SELinux restrictions from taking effect. no cap, be careful bestie โ ๏ธ
๐ฆ EXAMPLES ๐ฆ
Note that setpriv is not a 1:1 replacement for su(1), runuser(1), or sudo(8). Unlike those tools, setpriv does not use PAM, does not prompt for a password, and does not perform session or accounting setup. The examples below provide a starting point for common privilege-dropping scenarios โจ
If you want to switch UIDs/GIDs similarly to runuser(1) (without --login), try:
setpriv --reuid=1000 --regid=1000 --inh-caps=-all --init-groups
To also reset the environment (as sudo(8) does by default), add --reset-env:
setpriv --reuid=1000 --regid=1000 --inh-caps=-all --init-groups
--reset-env
For a more restrictive setup that also limits the bounding set and prevents gaining new privileges (more restrictive than runuser or sudo):
setpriv --reuid=1000 --regid=1000 --init-groups --inh-caps=-all
--bounding-set=-all --no-new-privs --reset-env
If you want to mimic daemontools' setuid(8), try:
setpriv --reuid=1000 --regid=1000 --clear-groups
๐ AUTHORS ๐
Andy Lutomirski <luto@amacapital.net> โ icon behavior honestly ๐
๐ SEE ALSO ๐
runuser(1), su(1), prctl(2), capabilities(7), landlock(7) โ go read these too, iykyk ๐
๐ REPORTING BUGS ๐
For bug reports, use the issue tracker <https://github.com/util-linux/util-linux/issues>. tell her everything, she can take it ๐
๐ง AVAILABILITY ๐ง
The setpriv command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/> โญ
and that's the whole page bestie!! this one's util-linux 2.42.4, dated 2026-09-21, and it's literally SETPRIV(1) โ main character energy, periodt ๐
๐๐
๐ฆ where this page comes from
- arch rolling: util-linux 2.42.4-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND ISC AND LGPL-2.1-or-later AND LicenseRef-PublicDomain
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms