$linuxjunkies
>

systemd-cgls(1)

Recursively show the contents of Linux control group hierarchies and their resource limits.

UbuntuDebianFedoraArch

Synopsis

systemd-cgls [OPTIONS] [CGROUP]

Description

systemd-cgls recursively shows the contents of the specified Linux control group (cgroup) hierarchy in a tree format. If no cgroup is specified, it defaults to the root cgroup of the current cgroup v2 hierarchy. This tool is useful for monitoring which processes belong to which cgroups and understanding systemd's resource management organization.

The output displays the cgroup tree structure with process information, memory usage, and other resource-related details depending on the cgroup version and specified options. It integrates with systemd's unified cgroup management and displays both v1 and v2 cgroups.

Common options

FlagWhat it does
-a, --allShow all cgroups recursively, including empty ones
-l, --fullDo not abbreviate cgroup or process names; show full paths
-k, --kibibytesUse binary (1024-byte) units instead of decimal (1000-byte) units
-M, --machine=CONTAINEROperate on a local container or machine instead of the local system
-n, --lines=INTEGERLimit output to the specified number of lines
-o, --output=TABLE|JSONOutput the cgroup tree in the specified format (default: tree)
-p, --pattern=PATTERNOnly show cgroups matching the specified pattern
-u, --unitShow cgroup information for systemd units
-h, --helpPrint help text and exit
--versionPrint version information and exit

Examples

Show the entire cgroup hierarchy starting from the root, displaying all cgroups and processes

systemd-cgls

Display only the cgroups and processes under the system.slice cgroup

systemd-cgls /system.slice

Show the user.slice cgroup with full (non-abbreviated) cgroup paths and process names

systemd-cgls -l /user.slice

Recursively list all cgroups including empty ones that have no processes

systemd-cgls --all

Show the cgroup hierarchy for a specific systemd service and all processes within it

systemd-cgls /system.slice/nginx.service

Output the cgroup hierarchy in JSON format for parsing by scripts or tools

systemd-cgls -o json

Show cgroups from a specific systemd machine/container instead of the local system

systemd-cgls --machine=mycontainer /

Show all user slice cgroups matching the pattern, including empty ones

systemd-cgls -p 'user-*.slice' -a

Related commands