CAPSH(1)
โจ CAPSH(1) โจ
okay bestie, sit down, hydrate, because we're about to talk about capsh โ the capability shell wrapper from the User Commands girlies ๐ it's literally a whole vibe and you're gonna be obsessed.
๐ NAME ๐
capsh โ capability shell wrapper ๐ฆ
๐ธ SYNOPSIS ๐ธ
capsh [OPTION]...
โจ DESCRIPTION โจ
okay so here's the tea โ โ Linux capability support and use can be explored and constrained with this tool. capsh is your handy little wrapper for certain types of capability testing and environment creation, no cap. It also gives you some debugging features that are genuinely useful for summarizing capability state. it's giving main character energy for capabilities fr fr ๐
๐ OPTIONS ๐
so capsh takes a bunch of optional arguments, and โ important โ it acts on them in the order they are provided. yes, order matters, she's sequential like that ๐
--helpโ Display the list of commands supported by capsh. your little "what can u even do" moment ๐ซถ--printโ Display prevailing capability and related state. the full vibe check, everything at once โจ--currentโ Display prevailing capability state, 1e capabilities and IAB vector. (yes it says 1e, that's not a typo bestie, that's the original)-- [args]โ Execute/bin/bashwith trailing arguments. note, you can use-c 'command to execute'for specific commands ๐-+ [args]โ Usescap_launch(3)to fork a child to execute the shell. When the child exits, capsh exits with the status of the child or1in the case that the child was terminated by a signal. dramatic but fair ๐== [args]โ Execute capsh again with the remaining arguments. Useful for testingexec()behavior. note,PATHis searched when the running capsh was found via the shell'sPATHsearching. If the exec occurs after a--chroot=/some/pathargument thePATHlocated binary may not be resolve to the same binary as that running initially. This behavior is an intended feature as it can complete the chroot transition. iykyk ๐ง=+ [args]โ Usescap_launch(3)to fork a child to re-execute capsh. When this child exits, capsh exits with the status of the child or1in the case that the child was terminated by a signal.--caps=cap-setโ Set the prevailing process capabilities to those specified by cap-set. Where cap-set is a text-representation of a capabilitySetas percap_text_formats(7). glow up ur capability set bestie ๐--drop=cap-listโ Remove the listed capabilities from the prevailing bounding set. The capabilities are a comma-separated list of capabilities as recognized by thecap_from_name(3)function. Use of this feature requires that capsh is operating withCAP_SETPCAPin its effective set. not me removing powers i literally need to do the removing ๐ญ--inh=cap-listโ Set the inheritable set of capabilities for the current process to equal those provided in the comma separated list. For this action to succeed, the prevailing process should already have each of these capabilities in the union of the current inheritable and permitted capability sets, or capsh should be operating withCAP_SETPCAPin its effective set.--user=usernameโ Assume the identity of the named user. That is, look up the user's UID and GID withgetpwuid(3)and their group memberships withgetgrouplist(3)and set them all usingcap_setuid(3)andcap_setgroups(3). Following this command, the effective capabilities will be cleared, but the permitted set will not be, so the running program is still privileged. โ ๏ธ yes she still has powers after the costume change.--modeโ Display the prevailing libcap mode as guessed by thecap_get_mode(3)function.--mode=<mode>โ Force the program into acap_set_mode(3)security mode. This is a set of securebits and prevailing capability arrangement recommended for its pre-determined security stance. pick ur fighter, she has opinions ๐--modesโ Lists all of the libcap modes supported by--mode=<mode>. the full menu, slay ๐--inmode=<mode>โ Confirm that the prevailing mode is that specified in<mode>, or exit with a status1. vibe check: are we in the right mode or are we lying ๐--uid=idโ Force all UID values to equal id using thesetuid(2)system call. This argument may require explicit preparation of the effective set.--cap-uid=<uid>โ use thecap_setuid(3)function to set the UID of the current process. This performs all preparations for setting the UID without dropping capabilities in the process. Following this command the prevailing effective capabilities will be lowered. lowkey a glow down but it's for safety ๐ซถ--is-uid=<id>โ Exit with status1unless the current UID equals<id>. bestie check ๐--gid=<id>โ Force all GID values to equal id using thesetgid(2)system call.--is-gid=<id>โ Exit with status1unless the current GIQ equals<id>. (yes, "GIQ" โ that's literally what the page says, we don't gatekeep the typo ๐ )--groups=<gid-list>โ Set the supplementary groups to the numerical list provided. The groups are set with thesetgroups(2)system call. See--userfor a more convenient way of doing this. the convenient route is right there bestie, take it โจ--keep=<0|1>โ In a non-pure capability mode, the kernel provides liberal privilege to the super-user. However, it is normally the case that when the super-user changes UID to some lesser user, then capabilities are dropped. For these situations, the kernel can permit the process to retain its capabilities after asetuid(2)system call. This feature is known as keep-caps support. The way to activate it using this program is with this argument. Setting the value to1will cause keep-caps to be active. Setting it to0will cause keep-caps to deactivate for the current process. In all cases, keep-caps is deactivated when anexec()is performed. See--secbitsand--modefor ways to disable this feature.
โ ๏ธ note: that's <lavender>--secbitsand--mode</lavender> in the original, we did not "fix" it, we do not touch the source text periodt.
--secbits=Nโ Set the security-bits for the program. This is done using theprctl(2)PR_SET_SECUREBITSoperation. The list of supported bits and their meaning can be found in the<sys/secbits.h>header file. The program will list these bits via the--printcommand. The argument is expressed as a numeric bitmask, in any of the formats permitted bystrtoul(3). An alternative to this bit-twiddling is embedded in the--mode*commandline arguments. bit-twiddling is so 2019, use the modes instead bestie ๐--chroot=/some/pathโ Execute thechroot(2)system call with the new root-directory (/) equal to path. This operation requiresCAP_SYS_CHROOTto be in effect. ๐--forkfor=secโ This command causes the program to fork a child process for so many seconds. The child will sleep that long and then exit with status0. The purpose of this command is to support exploring the way processes are killable in the face of capability changes. See the--killitcommand. Only one fork can be active at a time. no multitasking, she's monogamous with her forks ๐--killit=sigโ This commands causes a--forkforchild to bekill(2)d with the specified signal. The command then waits for the child to exit. If the exit status does not match the signal being used to kill it, the capsh program exits with status1. ๐--explain=cap_xxxโ Give a brief textual description of what privileges the specified capability makes available to a running program. note, instead ofcap_xxx, one can provide a decimal number and capsh will look up the corresponding capability's description. the "explain the lore" feature fr fr ๐--shell=/full/pathโ This option changes the shell that is invoked when the argument==is encountered.--strictโ This option toggles the suppression of subsequent attempts to fixup--caps=and--inh=arguments. That is, when the prevailingEffectiveflag does not containCAP_SETPCAPthe to be raisedInheritableFlag values (in strict mode) are limited to those in thePermittedset. The strict mode defaults to off. Supplying this argument an even number of times restores this default behavior. toggling like a light switch bestie, flip it twice and you're back ๐--suggest=phraseโ Scan each of the textual descriptions of capabilities, known to capsh, and display all descriptions that include phrase.--decode=Nโ This is a convenience feature. If you look at/proc/1/statusthere are some capability related fields of the following form:
CapInh: 0000000000000000
CapPrm: 0000003fffffffff
CapEff: 0000003fffffffff
CapBnd: 0000003fffffffff
CapAmb: 0000000000000000
This option provides a quick way to decode a capability vector represented in this hexadecimal form. Here's an example that decodes the two lowest capability bits:
$ capsh --decode=3
0x0000000000000003=cap_chown,cap_dac_override
โจ this is the one that makes everyone go "wait that's actually so useful" ๐ซถ
--supports=xxxโ As the kernel evolves, more capabilities are added. This option can be used to verify the existence of a capability on the system. For example,--supports=cap_syslogwill cause capsh to promptly exit with a status of1when run on kernel2.6.27. However, when run on kernel2.6.38it will silently succeed. era check, kernel edition ๐ง--has-p=xxxโ Exit with status1unless the permitted vector has capability xxx raised.--has-ambientโ Performs a check to see if the running kernel supports ambient capabilities. If not, capsh exits with status1.--has-a=xxxโ Exit with status1unless the ambient vector has capability xxx raised.--has-b=xxxโ Exit with status1unless the bounding vector has capability xxx in its (default) non-blocked state.--iab=xxxโ Attempts to set the IAB tuple of inheritable capability vectors. The text conventions used for xxx are those ofcap_iab_from_text(3), and described incap_text_formats(7).--addamb=xxxโ Adds the specified ambient capability to the running process. โจ--delamb=xxxโ Removes the specified ambient capability from the running process. ๐--noambโ Drops all ambient capabilities from the running process. she's clean, she's fresh, she has no ambient capabilities ๐ธ--noenvโ Suppresses overriding of theHOMEandUSERenvironment variables when a subsequent--userargument is processed.--quietโ This argument is ignored unless it is the first one. If present, it suppresses the capsh runtime check to confirm the running libcap is recent enough that it can name all of the kernel supported capability values. first or nothing bestie, she's picky like that ๐
๐ EXIT STATUS ๐
Following successful execution, capsh exits with status 0. Following an error, capsh immediately exits with status 1. no in-between, she's a binary girlie โจ
๐ซถ AUTHOR ๐ซถ
Written by Andrew G. Morgan <morgan@kernel.org>. the icon, the legend, the moment ๐
๐ญ REPORTING BUGS ๐ญ
Please report bugs via:
https://bugzilla.kernel.org/buglist.cgi?component=libcap&list_id=1090757
don't suffer in silence bestie, tell the bugzilla girlies ๐
๐ SEE ALSO ๐
libcap(3), cap_from_text(3), cap_iab(3), cap_text_formats(7), capabilities(7), captree(8), getcap(8), getpcaps(8), and setcap(8). the whole friend group, go say hi ๐ฆ
and that's the whole page bestie, you ate it ๐
okay so final sign-off: this is libcap, dated 2025-03-19, and honestly? iconic of it. periodt. ๐ธโจ๐
๐ฆ where this page comes from
- alpine 3.22: libcap-doc 2.78-r0 ยท BSD-3-Clause OR GPL-2.0-only
- alpine 3.23: libcap-doc 2.78-r0 ยท BSD-3-Clause OR GPL-2.0-only
- alpine 3.24: libcap-doc 2.78-r0 ยท BSD-3-Clause OR GPL-2.0-only
- arch rolling: libcap 2.78-1 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 43: libcap 2.76-3.fc43 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 43: libcap 2.76-3.fc43 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 43: libcap 2.76-4.fc43 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 43: libcap 2.76-4.fc43 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 44: libcap 2.77-2.fc44 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 44: libcap 2.77-2.fc44 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 44: libcap 2.78-1.fc44 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 44: libcap 2.78-1.fc44 ยท BSD-3-Clause OR GPL-2.0-only
- nixpkgs unstable: libcap 2.78
- ubuntu stonking: libcap2-bin 1:2.78-1ubuntu1 ยท BSD-3-Clause OR GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms