Linux – How to See Details of All Threads in a Process

command lineprocessshell

For Windows, I think Process Explorer shows you all the threads under a process.

Is there a similar command line utility for Linux that can show me details about all the threads a particular process is spawning?


I think I should have made myself more clear. I do not want to see the process hierarcy, but a list of all the threads spawned by a particular process

See this screenshot

alt text

How can this be achieved in Linux? Thanks!

Best Answer

The classical tool top shows processes by default but can be told to show threads with the H key press or -H command line option. There is also htop, which is similar to top but has scrolling and colors; it shows all threads by default (but this can be turned off). ps also has a few options to show threads, especially H and -L.

There are also GUI tools that can show information about threads, for example qps (a simple GUI wrapper around ps) or conky (a system monitor with lots of configuration options).

For each process, a lot of information is available in /proc/12345 where 12345 is the process ID. Information on each thread is available in /proc/12345/task/67890 where 67890 is the kernel thread ID. This is where ps, top and other tools get their information.

Related Question