Capabilities — Scoped Linux Privileges
Linux capabilities split many traditional superuser permissions into distinct privilege bits, evaluated in the context of the relevant user namespace and operation. Capabilities are per-thread. The effective set is checked for privileged operations, permitted limits what the thread may make effective, inheritable and ambient participate in exec transitions, and the bounding set constrains certain capability gains at exec. The ambient set, added in Linux 4.3, cannot contain bits absent from either permitted or inheritable. The actual outcome also depends on file permissions, LSM policy, namespace ownership and other checks. CAP_SYS_ADMIN covers many powerful operations and should not be used as a default workaround. UID alone cannot tell the entire privilege story. For multithreaded programs use /proc/thread-self/status to inspect the calling thread; /proc/self/status describes the thread-group leader. The single-threaded example parses only its own capability fields as hexadecimal masks and checks that effective is a subset of permitted. No capability is granted, removed or exercised. Do not change capability assignments to make an inspection succeed. Example prerequisites: Linux, Bash and Python 3 standard library; run as a non-root user in a private temporary working directory. Example scope: native read-only observation. Expected output: capability masks parsed; effective subset of permitted. No system configuration changes.
Formal Syntax & Structure
/proc/self/status: CapInh, CapPrm, CapEff, CapBnd, CapAmbParameters & Attributes
| Name | Type | Description |
|---|---|---|
| CapEff | hex bitmask | Effective capabilities. |
| CapPrm | hex bitmask | Permitted capabilities. |
| CapBnd | hex bitmask | Capability bounding set. |
| CapAmb | hex bitmask | Ambient capabilities. |
Return Value
Read-only bitmask inspection; output is normalized and does not expose host privilege data.
Working Example
python3 - <<'PY'from pathlib import Pathrows=dict(line.split(':',1) for line in Path('/proc/self/status').read_text().splitlines() if ':' in line)values={k:int(rows[k].strip(),16) for k in ('CapInh','CapPrm','CapEff','CapBnd','CapAmb')}assert all(v>=0 for v in values.values())assert values['CapEff'] & ~values['CapPrm']==0print('capability masks parsed; effective subset of permitted')PY