{
    "mode": "man",
    "parameter": "capsh",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/capsh/1/json",
    "generated": "2026-08-12T12:06:47Z",
    "synopsis": "capsh [OPTION]...",
    "sections": {
        "NAME": {
            "content": "capsh - capability shell wrapper\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "capsh [OPTION]...\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Linux  capability  support  and use can be explored and constrained with this tool. This tool\nprovides a handy wrapper for certain types of capability testing and environment creation. It\nalso provides some debugging features useful for summarizing capability state.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "capsh takes a number of optional arguments, acting on them in the order  they  are  provided.\nThey are as follows:\n\n--help Display the list of commands supported by capsh.\n",
            "subsections": [
                {
                    "name": "--print",
                    "content": "Display prevailing capability and related state.\n",
                    "long": "--print"
                },
                {
                    "name": "--current",
                    "content": "Display prevailing capability state, 1e capabilities and IAB vector.\n\n-- [args]\nExecute  /bin/bash  with trailing arguments. Note, you can use -c 'command to execute'\nfor specific commands.\n\n-+ [args]\nUses caplaunch(3) to fork a child to execute the shell. When the child  exits,  capsh\nexits with the status of the child or 1 in the case that the child was terminated by a\nsignal.\n\n== [args]\nExecute  capsh again with the remaining arguments. Useful for testing exec() behavior.\nNote, PATH is searched when the running capsh was found via the shell's  PATH  search‐\ning.  If  the exec occurs after a --chroot=/some/path argument the PATH located binary\nmay not be resolve to the same binary as that running initially. This behavior  is  an\nintended feature as it can complete the chroot transition.\n\n=+ [args]\nUses  caplaunch(3)  to fork a child to re-execute capsh. When this child exits, capsh\nexits with the status of the child or 1 in the case that the child was terminated by a\nsignal.\n\n--caps=cap-set\nSet the prevailing process capabilities to those specified by cap-set.  Where  cap-set\nis a text-representation of capability state as per capfromtext(3).\n\n--drop=cap-list\nRemove  the listed capabilities from the prevailing bounding set. The capabilities are\na comma-separated list of capabilities as recognized by the capfromname(3) function.\nUse of this feature requires that capsh is operating with CAPSETPCAP in its effective\nset.\n\n--inh=cap-list\nSet the inheritable set of capabilities for the current process to  equal  those  pro‐\nvided  in the comma separated list. For this action to succeed, the prevailing process\nshould already have each of these capabilities in the union of the current inheritable\nand permitted capability sets, or capsh should be operating with  CAPSETPCAP  in  its\neffective set.\n\n--user=username\nAssume  the  identity  of the named user. That is, look up the user's UID and GID with\ngetpwuid(3) and their group memberships with getgrouplist(3) and set  them  all  using\ncapsetuid(3)  and  capsetgroups(3).  Following this command, the effective capabili‐\nties will be cleared, but the permitted set will not be, so  the  running  program  is\nstill privileged.\n\n--mode Display the prevailing libcap mode as guessed by the capgetmode(3) function.\n\n--mode=<mode>\nForce  the  program  into a capsetmode(3) security mode. This is a set of securebits\nand prevailing capability arrangement  recommended  for  its  pre-determined  security\nstance.\n",
                    "long": "--current"
                },
                {
                    "name": "--modes",
                    "content": "Lists all of the libcap modes supported by --mode=<mode>.\n\n--inmode=<mode>\nConfirm that the prevailing mode is that specified in <mode>, or exit with a status 1.\n\n--uid=id\nForce  all  UID  values to equal id using the setuid(2) system call. This argument may\nrequire explicit preparation of the effective set.\n\n--cap-uid=<uid>\nuse the capsetuid(3) function to set the UID of the current  process.  This  performs\nall  preparations  for  setting  the UID without dropping capabilities in the process.\nFollowing this command the prevailing effective capabilities will be lowered.\n\n--is-uid=<id>\nExit with status 1 unless the current UID equals <id>.\n\n--gid=<id>\nForce all GID values to equal id using the setgid(2) system call.\n\n--is-gid=<id>\nExit with status 1 unless the current GIQ equals <id>.\n\n--groups=<gid-list>\nSet the supplementary groups to the numerical list provided. The groups are  set  with\nthe setgroups(2) system call. See --user for a more convenient way of doing this.\n\n--keep=<0|1>\nIn  a  non-pure  capability  mode, the kernel provides liberal privilege to the super-\nuser. However, it is normally the case that when the super-user changes  UID  to  some\nlesser  user, then capabilities are dropped. For these situations, the kernel can per‐\nmit the process to retain its capabilities after a setuid(2) system call. This feature\nis known as keep-caps support. The way to activate it using this program is with  this\nargument.  Setting  the  value to 1 will cause keep-caps to be active. Setting it to 0\nwill cause keep-caps to deactivate for the current process. In all cases, keep-caps is\ndeactivated when an exec() is performed. See --secbitsand--mode for  ways  to  disable\nthis feature.\n\n--secbits=N\nSet  the  security-bits  for  the program.  This is done using the prctl(2) PRSETSE‐\nCUREBITS operation.  The list of supported bits and their meaning can be found in  the\n<sys/secbits.h> header file. The program will list these bits via the --print command.\nThe  argument  is  expressed  as a numeric bitmask, in any of the formats permitted by\nstrtoul(3).  An alternative to this bit-twiddling is embedded in the --mode*  command‐\nline arguments.\n\n--chroot=/some/path\nExecute the chroot(2) system call with the new root-directory (/) equal to path.  This\noperation requires CAPSYSCHROOT to be in effect.\n\n--forkfor=sec\nThis command causes the program to fork a child process for so many seconds. The child\nwill  sleep  that  long and then exit with status 0. The purpose of this command is to\nsupport exploring the way processes are killable in the face  of  capability  changes.\nSee the --killit command. Only one fork can be active at a time.\n\n--killit=sig\nThis  commands  causes a --forkfor child to be kill(2)d with the specified signal. The\ncommand then waits for the child to exit.  If the exit status does not match the  sig‐\nnal being used to kill it, the capsh program exits with status 1.\n\n--explain=capxxx\nGive  a  brief  textual  description of what privileges the specified capability makes\navailable to a running program. Note, instead of capxxx, one can  provide  a  decimal\nnumber and capsh will look up the corresponding capability's description.\n\n--shell=/full/path\nThis option changes the shell that is invoked when the argument == is encountered.\n",
                    "long": "--modes"
                },
                {
                    "name": "--strict",
                    "content": "This option toggles the suppression of subsequent attempts to fixup --caps= and --inh=\narguments.  That  is,  when the prevailing Effective flag does not contain CAPSETPCAP\nthe to be raised Inheritable Flag values (in strict mode) are limited to those in  the\nPermitted set. The strict mode defaults to off. Supplying this argument an even number\nof times restores this default behavior.\n\n--suggest=phrase\nScan each of the textual descriptions of capabilities, known to capsh, and display all\ndescriptions that include phrase.\n\n--decode=N\nThis is a convenience feature. If you look at /proc/1/status there are some capability\nrelated fields of the following form:\n\nCapInh:   0000000000000000\nCapPrm:   0000003fffffffff\nCapEff:   0000003fffffffff\nCapBnd:   0000003fffffffff\nCapAmb:   0000000000000000\n\nThis  option  provides  a  quick way to decode a capability vector represented in this\nhexadecimal form.  Here's an example that decodes the two lowest capability bits:\n\n$ capsh --decode=3\n0x0000000000000003=capchown,capdacoverride\n\n--supports=xxx\nAs the kernel evolves, more capabilities are added. This option can be used to  verify\nthe  existence  of a capability on the system. For example, --supports=capsyslog will\ncause capsh to promptly exit with a status of 1 when run on kernel  2.6.27.   However,\nwhen run on kernel 2.6.38 it will silently succeed.\n\n--has-p=xxx\nExit with status 1 unless the permitted vector has capability xxx raised.\n",
                    "long": "--strict"
                },
                {
                    "name": "--has-ambient",
                    "content": "Performs  a  check to see if the running kernel supports ambient capabilities. If not,\ncapsh exits with status 1.\n\n--has-a=xxx\nExit with status 1 unless the ambient vector has capability xxx raised.\n\n--has-b=xxx\nExit with status 1 unless the bounding vector has capability xxx in its (default) non-\nblocked state.\n\n--iab=xxx\nAttempts to set the IAB tuple of inheritable capability vectors.  The text conventions\nused for xxx are those of capiabfromtext(3).\n\n--addamb=xxx\nAdds the specified ambient capability to the running process.\n\n--delamb=xxx\nRemoves the specified ambient capability from the running process.\n",
                    "long": "--has-ambient"
                },
                {
                    "name": "--noamb",
                    "content": "Drops all ambient capabilities from the running process.\n",
                    "long": "--noamb"
                },
                {
                    "name": "--noenv",
                    "content": "Suppresses overriding of the HOME and USER environment  variables  when  a  subsequent\n--user argument is processed.\n",
                    "long": "--noenv"
                },
                {
                    "name": "--quiet",
                    "content": "This  argument  is  ignored  unless it is the first one. If present, it suppresses the\ncapsh runtime check to confirm the running libcap is recent enough that  it  can  name\nall of the kernel supported capability values.\n",
                    "long": "--quiet"
                }
            ]
        },
        "EXIT STATUS": {
            "content": "Following  successful execution, capsh exits with status 0. Following an error, capsh immedi‐\nately exits with status 1.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Written by Andrew G. Morgan <morgan@kernel.org>.\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "Please report bugs via:\n\nhttps://bugzilla.kernel.org/buglist.cgi?component=libcap&listid=1090757\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "libcap(3), capfromtext(3), capiab(3) capabilities(7), captree(8), getcap(8),  getpcaps(8),\nand setcap(8).\n\nlibcap                                       2021-10-22                                     CAPSH(1)",
            "subsections": []
        }
    },
    "summary": "capsh - capability shell wrapper",
    "flags": [
        {
            "flag": "",
            "long": "--print",
            "arg": null,
            "description": "Display prevailing capability and related state."
        },
        {
            "flag": "",
            "long": "--current",
            "arg": null,
            "description": "Display prevailing capability state, 1e capabilities and IAB vector. -- [args] Execute /bin/bash with trailing arguments. Note, you can use -c 'command to execute' for specific commands. -+ [args] Uses caplaunch(3) to fork a child to execute the shell. When the child exits, capsh exits with the status of the child or 1 in the case that the child was terminated by a signal. == [args] Execute capsh again with the remaining arguments. Useful for testing exec() behavior. Note, PATH is searched when the running capsh was found via the shell's PATH search‐ ing. If the exec occurs after a --chroot=/some/path argument the PATH located 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. =+ [args] Uses caplaunch(3) to fork a child to re-execute capsh. When this child exits, capsh exits with the status of the child or 1 in 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 capability state as per capfromtext(3). --drop=cap-list Remove the listed capabilities from the prevailing bounding set. The capabilities are a comma-separated list of capabilities as recognized by the capfromname(3) function. Use of this feature requires that capsh is operating with CAPSETPCAP in its effective set. --inh=cap-list Set the inheritable set of capabilities for the current process to equal those pro‐ vided 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 with CAPSETPCAP in its effective set. --user=username Assume the identity of the named user. That is, look up the user's UID and GID with getpwuid(3) and their group memberships with getgrouplist(3) and set them all using capsetuid(3) and capsetgroups(3). Following this command, the effective capabili‐ ties will be cleared, but the permitted set will not be, so the running program is still privileged. --mode Display the prevailing libcap mode as guessed by the capgetmode(3) function. --mode=<mode> Force the program into a capsetmode(3) security mode. This is a set of securebits and prevailing capability arrangement recommended for its pre-determined security stance."
        },
        {
            "flag": "",
            "long": "--modes",
            "arg": null,
            "description": "Lists all of the libcap modes supported by --mode=<mode>. --inmode=<mode> Confirm that the prevailing mode is that specified in <mode>, or exit with a status 1. --uid=id Force all UID values to equal id using the setuid(2) system call. This argument may require explicit preparation of the effective set. --cap-uid=<uid> use the capsetuid(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. --is-uid=<id> Exit with status 1 unless the current UID equals <id>. --gid=<id> Force all GID values to equal id using the setgid(2) system call. --is-gid=<id> Exit with status 1 unless the current GIQ equals <id>. --groups=<gid-list> Set the supplementary groups to the numerical list provided. The groups are set with the setgroups(2) system call. See --user for a more convenient way of doing this. --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 per‐ mit the process to retain its capabilities after a setuid(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 to 1 will cause keep-caps to be active. Setting it to 0 will cause keep-caps to deactivate for the current process. In all cases, keep-caps is deactivated when an exec() is performed. See --secbitsand--mode for ways to disable this feature. --secbits=N Set the security-bits for the program. This is done using the prctl(2) PRSETSE‐ CUREBITS operation. 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 --print command. The argument is expressed as a numeric bitmask, in any of the formats permitted by strtoul(3). An alternative to this bit-twiddling is embedded in the --mode* command‐ line arguments. --chroot=/some/path Execute the chroot(2) system call with the new root-directory (/) equal to path. This operation requires CAPSYSCHROOT to 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 status 0. The purpose of this command is to support exploring the way processes are killable in the face of capability changes. See the --killit command. Only one fork can be active at a time. --killit=sig This commands causes a --forkfor child to be kill(2)d with the specified signal. The command then waits for the child to exit. If the exit status does not match the sig‐ nal being used to kill it, the capsh program exits with status 1. --explain=capxxx Give a brief textual description of what privileges the specified capability makes available to a running program. Note, instead of capxxx, one can provide a decimal number and capsh will look up the corresponding capability's description. --shell=/full/path This option changes the shell that is invoked when the argument == is encountered."
        },
        {
            "flag": "",
            "long": "--strict",
            "arg": null,
            "description": "This option toggles the suppression of subsequent attempts to fixup --caps= and --inh= arguments. That is, when the prevailing Effective flag does not contain CAPSETPCAP the to be raised Inheritable Flag values (in strict mode) are limited to those in the Permitted set. The strict mode defaults to off. Supplying this argument an even number of times restores this default behavior. --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/status there 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=capchown,capdacoverride --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=capsyslog will cause capsh to promptly exit with a status of 1 when run on kernel 2.6.27. However, when run on kernel 2.6.38 it will silently succeed. --has-p=xxx Exit with status 1 unless the permitted vector has capability xxx raised."
        },
        {
            "flag": "",
            "long": "--has-ambient",
            "arg": null,
            "description": "Performs a check to see if the running kernel supports ambient capabilities. If not, capsh exits with status 1. --has-a=xxx Exit with status 1 unless the ambient vector has capability xxx raised. --has-b=xxx Exit with status 1 unless 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 of capiabfromtext(3). --addamb=xxx Adds the specified ambient capability to the running process. --delamb=xxx Removes the specified ambient capability from the running process."
        },
        {
            "flag": "",
            "long": "--noamb",
            "arg": null,
            "description": "Drops all ambient capabilities from the running process."
        },
        {
            "flag": "",
            "long": "--noenv",
            "arg": null,
            "description": "Suppresses overriding of the HOME and USER environment variables when a subsequent --user argument is processed."
        },
        {
            "flag": "",
            "long": "--quiet",
            "arg": null,
            "description": "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."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "libcap",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/libcap/3/json"
        },
        {
            "name": "capfromtext",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/capfromtext/3/json"
        },
        {
            "name": "capiab",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/capiab/3/json"
        },
        {
            "name": "capabilities",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/capabilities/7/json"
        },
        {
            "name": "captree",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/captree/8/json"
        },
        {
            "name": "getcap",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/getcap/8/json"
        },
        {
            "name": "getpcaps",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/getpcaps/8/json"
        },
        {
            "name": "setcap",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/setcap/8/json"
        }
    ]
}