$linuxjunkies
>

capabilities

also: Linux capabilities, cap_*

Linux capabilities are granular permissions that allow processes to perform specific privileged operations without needing full root access. They divide root's power into distinct abilities that can be independently granted or revoked.

Traditionally, Linux processes are either privileged (running as root with UID 0) or unprivileged. Capabilities provide a finer-grained security model by splitting root's authority into over 40 distinct permissions, each controlling a specific privileged action like binding to ports below 1024, changing file ownership, or loading kernel modules.

Each capability has a name like CAP_NET_BIND_SERVICE (bind to privileged ports) or CAP_SETUID (change process UID). These can be attached to executable files or granted to running processes, allowing a program to perform only the specific privileged operations it needs.

For example, the ping utility needs to create raw sockets, which normally requires root. Instead of running as root, ping can have only CAP_NET_RAW. This follows the principle of least privilege: if the program is compromised, an attacker gains only the specific capabilities it holds, not full root access.

You can view a process's capabilities with getcap and set them with setcap. For instance: setcap cap_net_bind_service=+ep /usr/bin/myapp grants a binary the ability to bind to privileged ports.

Related terms