Linux Capabilities
Linux capabilities subdivide root privileges — getcap, setcap, capsh, and Docker cap-drop patterns.
Overview
Traditionally, Linux privilege was binary: you either had root (UID 0) and could do anything, or you were an unprivileged user. Linux capabilities break this model by dividing root's all-powerful authority into about 40 distinct privilege units that can be granted or revoked independently.
Why Capabilities Matter
Running a process as root just to bind port 80 is a massive security over-grant. With capabilities, you grant only CAP_NET_BIND_SERVICE and nothing else. A vulnerability in the service then cannot be exploited to write to /etc/passwd or load kernel modules, because the process never held those powers.
Key concepts
- CAP_NET_BIND_SERVICE
- CAP_SYS_ADMIN
- setcap
- getcap
- capsh
- Docker --cap-drop/--cap-add
Interview questions
- How do you allow a non-root application to bind to port 80 using capabilities instead of running as root?
- Walk through capability sets — permitted, effective, inheritable, ambient, and bounding. How do they interact?
Sign up free to read the full topic
More Linux topics
Start free on Cariara · Coding problems · System design studio