« Back to Processes: Frequently Asked Questions

How to see cgroup in ps output

How to see cgroup in ps output?

Run the ps command and select the columns 'pid' and 'cgroup' by using the option -o.

ps -e -o pid,cgroup:64,args

The ps command can show the control group of a process using the -o option, followed by the right column names.

Usage

To show processes and the control group, we can filter the output columns.

# ps -e -o pid,cgroup:64,args
    PID CGROUP                                                           COMMAND
      1 0::/init.scope                                                   /lib/systemd/systemd --system --deserialize 58
      2 -                                                                [kthreadd]
      3 -                                                                [rcu_gp]
<snip>
    576 -                                                                [xprtiod]
    634 0::/system.slice/dbus.service                                    @dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
    640 0::/system.slice/networkd-dispatcher.service                     /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
    645 -                                                                [nfsiod]
    653 0::/system.slice/systemd-logind.service                          /lib/systemd/systemd-logind
    696 0::/system.slice/system-getty.slice/getty@tty1.service           /sbin/agetty -o -p -- \u --noclear tty1 linux

In this example the PID is displayed, with the control group, and the command with its arguments. By specifying the width of 64 characters, we can properly see the full name of the control group.

Other questions related to Processes

    Related articles

    Like to learn more? Here is a list of articles within the same category or having similar tags.

    Feedback

    Small picture of Michael Boelen

    This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

    Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

    Mastodon icon