Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to be able to get the number of thread per process in command-line and get the exact same number I can see via the Activity Monitor.

At the moment the IntelliJ IDEA process (PID 5235) has 266 Thread. I'd like to get this number but via a command line.

I've tried

lsof -p 5235 | wc -l

Any suggestions?

share|improve this question

migrated from May 15 '14 at 7:03

This question came from our site for system and network administrators.

up vote 4 down vote accepted

Try the following:

NUM=`ps M <pid> | wc -l | xargs` && expr $NUM - 1
share|improve this answer
Exactly what I was looking for. Thanks you so much ;) – TheEwook May 15 '14 at 9:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.