Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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 wonder how to get how many cores (including emulated via HT and such) are avaliable to user via bash shell-script command?

share|improve this question
On what operating system? – Mat Jan 15 '12 at 8:44
Debian, Ubuntu, OpenSuse, MacOsX – myWallJSON Jan 15 '12 at 9:25
up vote 6 down vote accepted

On Linux:

grep ^processor /proc/cpuinfo | wc -l
share|improve this answer
Or try grep -c ^processor /proc/cpuinfo and you won't need to spawn two processes. – Alexios Jan 15 '12 at 10:36

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.