What is the most general way to list all the kernel tasks in a linux system? What is the most general way to list all the kernel tasks in a linux system? shell shell

What is the most general way to list all the kernel tasks in a linux system?


If you want to distinguish user processes from kernel tasks, then this is a previous discussion on the subject: Identifying kernel threads

My answer to that question does not require any tools, it simply reads the contents of /proc//stat, so it should work on any distribution.


You could try

ps -e -o pgrp= -o pid= -o cmd= | sed -ne 's/^ *0 *// p'

although it assumes all kernel tasks belong to process group 0.