What it does
systemd puts every service, user session and container in its own cgroup, grouped in slices: system.slice, user.slice, machine.slice. systemd-cgls shows which process belongs to which service — useful when ps does not tell you where a process comes from. systemd-cgtop shows CPU, memory and I/O per cgroup, like top.
How to write it
systemd-cgls [OPTION]... [CGROUP...]
systemd-cgls [OPTION]... --unit|--user-unit [UNIT...]
systemd-cgtop [OPTION]... [GROUP]Options 26
Most used
systemd-cgls
systemd-cgtop
Nothing matches this filter.
Examples 10
$ run as a normal user# run as root (or with sudo)
1The whole tree
systemd-cgls --no-pager | head -25Slices, services and their processes.
2One service
systemd-cgls -u httpd.serviceAll processes of the web server, also CGI children.
3Where does this process come from?
systemctl status 4123Shows the unit and cgroup of a PID.
4Your own session
systemd-cgls -u user-1000.sliceEverything you started.
5Live resource use per service
systemd-cgtopPress m, c, i to sort.
6Sorted by memory, one snapshot
systemd-cgtop -m -1 -b | headFor a report.
7Container processes
systemd-cgls -u machine.sliceVMs and containers.
8Cgroup of a process directly
cat /proc/4123/cgroup 0::/system.slice/httpd.servicecgroup v2 path.
9Limit a service with cgroups
systemctl set-property httpd.service MemoryMax=1G CPUQuota=50%Resource limits are set on the cgroup.
10Find hidden processes of a service (security)
systemd-cgls -u sshd.serviceA strange child (like a miner) under a service shows up here.
Nothing matches this filter.
Exit codes
0 | Done. |
1 | Error. |