Linux Kernel Capabilities: Which Powers Does a Program Need?
Suppose a Linux service can't start because it lacks permission to use a particular network port. Running it as the administrator might clear the error. It could also give that small program far more authority than the job requires.
Linux kernel capabilities split powers traditionally associated with root, the administrator account, into separately controlled permissions. The kernel is the central part of the operating system that manages resources and enforces these checks. A privilege allows an operation that ordinary programs can't normally perform.
Capabilities are often described as belonging to a process, a running program. More precisely, Linux tracks them per thread, an execution path within a process. A process can contain several threads. The Linux capabilities manual explains the distinction.
Why Should an Account Get Only What It Needs?
Permission for a Particular Job
Return to that hypothetical service, a program providing something over the network. A port is a numbered communication endpoint that directs traffic to the right service. Binding attaches the program to a local address and port so it can receive traffic there.
Linux provides CAP_NET_BIND_SERVICE for binding to privileged Internet ports. Subject to the system's configuration, this capability can let the service listen there without the traditional full set of root privileges.
Other capabilities cover different jobs. CAP_SYS_TIME permits clock changes. CAP_NET_ADMIN covers several network administration tasks, including changes to routing tables, the records used to choose where traffic goes next. The kernel's capability definitions describe these permissions.
Some grants are much broader. CAP_SYS_ADMIN covers a long list of administrative operations. A program holding “just one capability” may still have extensive power, so counting names tells you little about how restricted it is.
- Finally understand what the commands you type are doing behind the scenes.
- Fix problems yourself instead of pasting in fixes you found online and hoping.
- Go from following tutorials to knowing why they work, one clear chapter at a time.
Selecting permissions carefully applies least privilege: allow the authority needed for the job. If someone takes over the service, removing unnecessary capabilities leaves fewer privileged operations available to misuse.
Which Powers Are Active?
A capability can be available to a thread without being in use. The effective set contains capabilities currently used for permission checks. The permitted set limits which ones the thread can make effective.
Further rules govern what happens when a program starts another executable, a file containing runnable code. File capabilities can grant privileges when that file runs. They're different from the ordinary permissions controlling who may read or edit the file.
A service manager, which starts and supervises services, can control how they receive capabilities. For example, systemd's capability settings support running a service as an ordinary user while giving it selected capabilities.
Its CapabilityBoundingSet setting limits capability availability. AmbientCapabilities supplies selected capabilities to the service. Neither setting, read in isolation, is a report of every power active in the running program.
The configuration describes the intended setup; the running program's capability sets show its current state. Check both before treating a permission problem as a reason to add another grant.
What Is a Kernel?
Root Inside a Container
A container runs applications with selected forms of isolation from the surrounding computer. One mechanism that can help provide this separation is a namespace, which gives software a separate view of certain system resources.
Linux user namespaces can give a program root identity and capabilities within a defined scope while it remains unprivileged outside that scope. A container using this arrangement can have its own root user without granting that user unrestricted root authority over the host computer.
Capabilities are checked against the namespace governing the resource involved. Some operations affecting the whole system require authority in the initial user namespace, the system's original one. The Linux user-namespace manual explains these boundaries.
The same capability name can therefore describe authority over different resources. A container review needs to establish which namespaces it uses and where its permissions apply.
- Run a test server or a home lab without giving up desk space.
- Start right away with 16GB of memory and a 500GB SSD already inside.
- Drive two 4K screens when it doubles as an everyday desktop.
Limiting the Next Program
Linux also has a control called no new privileges, written no_new_privs. Once set, the flag can't be turned off. New processes started by the program inherit it. It blocks gaining certain privileges when starting another executable, including gains through file capabilities.
The kernel's no-new-privileges documentation describes the boundary: the flag restricts privilege gains through starting another executable, rather than every possible change in authority. It leaves existing privileges in place.
For the service that failed to start, the aim is a narrow, understood grant that allows its work. Clearing the error by adding a broad capability may also authorize operations it never needed. Those extra permissions remain available if the service is later compromised.
Least Privilege: Give Each Account the Power Its Work Needs

Root: The Account Behind a Program’s Administrative Power

Mandatory Access Control: Even the Owner May Be Told No

QUOTE:
"Amateurs hack systems, professionals hack people."

