# man > CAPSH(1)

[_CAPSH_(1)](https://www.chedong.com/phpMan.php/man/CAPSH/1/markdown)                                    User Commands                                   [_CAPSH_(1)](https://www.chedong.com/phpMan.php/man/CAPSH/1/markdown)

## NAME
       capsh - capability shell wrapper

## SYNOPSIS
       **capsh **[_OPTION_]...

## DESCRIPTION
       Linux  capability  support  and use can be explored and constrained with this tool. This tool
       provides a handy wrapper for certain types of capability testing and environment creation. It
       also provides some debugging features useful for summarizing capability state.

## OPTIONS
       **capsh **takes a number of optional arguments, acting on them in the order  they  are  provided.
       They are as follows:

       **--help **Display the list of commands supported by **capsh**.

### --print
              Display prevailing capability and related state.

### --current
              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 [**cap_launch**(3)](https://www.chedong.com/phpMan.php/man/caplaunch/3/markdown) 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  [**cap_launch**(3)](https://www.chedong.com/phpMan.php/man/caplaunch/3/markdown)  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 [**cap_from_text**(3)](https://www.chedong.com/phpMan.php/man/capfromtext/3/markdown).

       **--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 [**cap_from_name**(3)](https://www.chedong.com/phpMan.php/man/capfromname/3/markdown) function.
              Use of this feature requires that **capsh **is operating with **CAP_SETPCAP **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  **CAP_SETPCAP  **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)](https://www.chedong.com/phpMan.php/man/getpwuid/3/markdown) and their group memberships with [**getgrouplist**(3)](https://www.chedong.com/phpMan.php/man/getgrouplist/3/markdown) and set  them  all  using
              [**cap_setuid**(3)](https://www.chedong.com/phpMan.php/man/capsetuid/3/markdown)  and  [**cap_setgroups**(3)](https://www.chedong.com/phpMan.php/man/capsetgroups/3/markdown).  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 [**cap_get_mode**(3)](https://www.chedong.com/phpMan.php/man/capgetmode/3/markdown) function.

       **--mode=**<mode>
              Force  the  program  into a [**cap_set_mode**(3)](https://www.chedong.com/phpMan.php/man/capsetmode/3/markdown) security mode. This is a set of securebits
              and prevailing capability arrangement  recommended  for  its  pre-determined  security
              stance.

### --modes
              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)](https://www.chedong.com/phpMan.php/man/setuid/2/markdown) system call. This argument may
              require explicit preparation of the effective set.

       **--cap-uid=**<uid>
              use the [**cap_setuid**(3)](https://www.chedong.com/phpMan.php/man/capsetuid/3/markdown) 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)](https://www.chedong.com/phpMan.php/man/setgid/2/markdown) 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)](https://www.chedong.com/phpMan.php/man/setgroups/2/markdown) 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)](https://www.chedong.com/phpMan.php/man/setuid/2/markdown) 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 **--secbits**and**--mode **for  ways  to  disable
              this feature.

       **--secbits=_**N_
              Set  the  security-bits  for  the program.  This is done using the [**prctl**(2)](https://www.chedong.com/phpMan.php/man/prctl/2/markdown) **PR_SET_SE‐**
              **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)](https://www.chedong.com/phpMan.php/man/strtoul/3/markdown).  An alternative to this bit-twiddling is embedded in the **--mode*  **command‐
              line arguments.

       **--chroot=_**/some/path_
              Execute the [**chroot**(2)](https://www.chedong.com/phpMan.php/man/chroot/2/markdown) system call with the new root-directory (/) equal to _path_.  This
              operation requires **CAP_SYS_CHROOT **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)](https://www.chedong.com/phpMan.php/man/kill/2/markdown)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=_**cap_xxx_
              Give  a  brief  textual  description of what privileges the specified capability makes
              available to a running program. Note, instead of _cap_xxx_, 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.

### --strict
              This option toggles the suppression of subsequent attempts to fixup **--caps= **and **--inh=**
              arguments.  That  is,  when the prevailing Effective flag does not contain **CAP_SETPCAP**
              **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=cap_chown,cap_dac_override

       **--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_syslog_ 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.

### --has-ambient
              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 [**cap_iab_from_text**(3)](https://www.chedong.com/phpMan.php/man/capiabfromtext/3/markdown).

       **--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.

### --noenv
              Suppresses overriding of the HOME and USER environment  variables  when  a  subsequent
              **--user **argument 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.

## EXIT STATUS
       Following  successful execution, **capsh **exits with status 0. Following an error, **capsh **immedi‐
       ately exits with status 1.

## AUTHOR
       Written by Andrew G. Morgan <<morgan@kernel.org>>.

## REPORTING BUGS
       Please report bugs via:

       <https://bugzilla.kernel.org/buglist.cgi?component=libcap&list_id=1090757>

## SEE ALSO
       [**libcap**(3)](https://www.chedong.com/phpMan.php/man/libcap/3/markdown), [**cap_from_text**(3)](https://www.chedong.com/phpMan.php/man/capfromtext/3/markdown), [**cap_iab**(3)](https://www.chedong.com/phpMan.php/man/capiab/3/markdown) [**capabilities**(7)](https://www.chedong.com/phpMan.php/man/capabilities/7/markdown), [**captree**(8)](https://www.chedong.com/phpMan.php/man/captree/8/markdown), [**getcap**(8)](https://www.chedong.com/phpMan.php/man/getcap/8/markdown),  [**getpcaps**(8)](https://www.chedong.com/phpMan.php/man/getpcaps/8/markdown),
       and [**setcap**(8)](https://www.chedong.com/phpMan.php/man/setcap/8/markdown).

libcap                                       2021-10-22                                     [_CAPSH_(1)](https://www.chedong.com/phpMan.php/man/CAPSH/1/markdown)
