Commands.page Logo

How to View Cgroup Info in Htop on Ubuntu

This guide explains how to inspect control group (cgroup) data for specific processes using the htop system monitor on Ubuntu. You will learn how to configure htop columns to display cgroup paths, enabling better resource management and troubleshooting for containerized or systemd-managed applications.

Install and Launch Htop

Ensure htop is installed on your Ubuntu system. Open your terminal and run the following command:

sudo apt update
sudo apt install htop

Once installed, launch the tool by typing htop in the terminal and pressing Enter.

Configure Display Columns

By default, htop may not show cgroup information. To enable this view, press the F2 key to open the Setup menu. Navigate to the Columns tab using the arrow keys or mouse.

In the available columns list on the left, scroll down until you find CGROUP. Select it and press the + key or click the add button to move it to the active columns list on the right. Use the F5 key or the arrow buttons to arrange the order if desired. Press F10 or click Done to save changes and return to the main view.

Interpret Cgroup Data

The main screen now displays a CGROUP column for each process. This field shows the hierarchy path assigned to the process. For systemd services, you will see paths starting with /user.slice or /system.slice. For Docker or Kubernetes containers, the path typically includes /docker or /kubepods.

You can sort processes by this column by pressing F6, selecting CGROUP, and pressing Enter. This groups related processes together, making it easier to analyze resource usage per container or service unit.

Verify with Command Line

If you need to cross-reference the information seen in htop, you can view the cgroup details for a specific process ID (PID) directly from the terminal. Run the following command, replacing <PID> with the actual process ID:

cat /proc/<PID>/cgroup

This output should match the path displayed in the htop CGROUP column, confirming the process membership within the system control groups.