Inspect Linux Process Capabilities with getpcaps on Ubuntu

Overview

Linux decouples traditional superuser omnipotence into discrete privileges known as POSIX capabilities. This tutorial explores hands-on auditing of these fine-grained attributes using the getpcaps diagnostic utility, detailing how to evaluate running processes and correctly decipher kernel privilege notations.

1. Setting Up the libcap Toolkit on Ubuntu

To obtain the capability management suite, install the official libcap2-bin runtime package via APT:

Install libcap2-bin package

Verify proper installation and locate the binary path within your search environment using which getpcaps:

Locate getpcaps utility binary path

2. Inspecting Standard User Processes and Interpreting Flags

Launch a non-privileged background workload with sleep 100 & to serve as an evaluation target:

Execute sleep command in background

Capture the process identifier of the newly dispatched background job into a shell variable:

Save background process ID

Query the privilege sets assigned to the target PID by issuing getpcaps $TARGET_PID.
When the output yields =ep, it indicates that the process inherited an unrestricted scope across both the Effective and Permitted privilege sets under the current execution context:

Audit process capabilities using getpcaps

Terminate the dummy test workload once analysis concludes:

Kill test background process

3. Auditing Elevated System Daemon Privileges

Extract the process ID of an active core system daemon—such as network resolution services or init—into an environment variable:

Query system daemon process ID

Inspect the elevated capability profile of the targeted system service using getpcaps $SYSTEMD_PID.
An expression like cap_net_raw=eip demonstrates that raw socket generation (cap_net_raw) is actively enabled across the Effective, Inheritable, and Permitted credential sets:

Display daemon capability flags

4. Capability Assignment Workflow and Runtime Verification

To safely experiment with permission assignment without touching system binaries, duplicate the standard ping utility locally:

Duplicate ping binary to local directory

Grant the cloned executable raw networking authorization using file-based capabilities via sudo setcap cap_net_raw+ep ./my_ping:

Assign file capability flags with setcap

Spawn the newly configured executable in the background to monitor its runtime security context:

Run modified binary in background

Retain the operational PID of this newly initiated task:

Store running ping process identifier

Audit the operational capabilities of the active task with getpcaps $PING_PID.
A lone = output signifies an empty capability set; unprivileged invocation contexts often strip or fail to inherit targeted file capabilities during runtime transitions unless explicit inheritance flags are preserved:

Inspect effective runtime privileges with getpcaps

Halt the ongoing background network ping process:

Terminate background ping task

Remove the temporary executable to keep your working environment clean:

Delete temporary binary file

Leveraging getpcaps offers crucial visibility into how privileges are scoped and distributed across modern Linux distributions. Applying least-privilege principles by confining processes to strictly necessary capabilities remains a pillar of robust server hardening.