Linux capabilities break the monolithic privilege of root into individual, grantable units. Instead of running a whole program as root to do one privileged thing, you grant just the capability it needs. This reference lists the capability constants with the exact power each confers and a risk rating.
How it works
Each capability is a named bit (e.g. CAP_NET_BIND_SERVICE) that authorizes a
specific class of privileged operations. A process carries several capability
sets — permitted, effective, inheritable, bounding and ambient — that together
decide which privileges are active. Executables can also carry file
capabilities, granted on exec, which replace the old setuid-root pattern.
The risk rating here is practical guidance: some capabilities are narrow and safe
(CAP_NET_BIND_SERVICE), while others — CAP_SYS_ADMIN, CAP_SYS_MODULE,
CAP_BPF, CAP_DAC_OVERRIDE — are powerful enough to be treated as equivalent
to full root.
Example
To let a service bind port 443 without root, drop all capabilities and grant only the one it needs:
setcap cap_net_bind_service=+ep /usr/local/bin/myserver
getcap /usr/local/bin/myserver
# /usr/local/bin/myserver cap_net_bind_service=ep
The binary can now bind privileged ports while running as an unprivileged user.
Notes
- Inspect a running process with
cat /proc/PID/status | grep Capand decode the hex masks withcapsh --decode=<hex>. - Dropping capabilities in a container (
--cap-drop=ALLthen--cap-addonly what you need) dramatically shrinks the attack surface. CAP_SYS_PTRACElets a process read any other process’s memory — keep it out of multi-tenant environments.- Capabilities pair with seccomp, namespaces and cgroups; alone they are not a full sandbox.