# Identify Process Cgroup by PID ## TL;DR You can identify a process's cgroup by reading `/proc//cgroup`. ## Outcome Multiple methods to find which cgroup a process belongs to using its PID. ## Conversation **Question:** Can I identify the process's cgroup by having its PID? **Answer:** Yes, here are the main methods: ### Method 1: Read `/proc//cgroup` ```bash cat /proc//cgroup ``` This shows all cgroup controllers the process belongs to. For example: ``` 12:blkio:/user.slice 11:memory:/user.slice/user-1000.slice ... 0::/user.slice/user-1000.slice/session-1.scope ``` ### Method 2: Using `ps` with format options ```bash ps -o pid,cgroup -p ``` ### Method 3: Using `systemd-cgls` If you're on a systemd system: ```bash systemd-cgls --unit # or to see the whole tree systemd-cgls ``` ### Method 4: Check cgroup v2 unified hierarchy On cgroup v2 systems, check: ```bash cat /proc//cgroup # Output will look like: 0::/user.slice/user-1000.slice/session-1.scope ``` The path after `::` is the cgroup path under `/sys/fs/cgroup/`. ### Quick one-liner ```bash cat /proc/self/cgroup # For current shell cat /proc/$$/cgroup # Also current shell cat /proc/1234/cgroup # For PID 1234 ```