On Linux, how to tell how many cores of the machine are active?












12















On Linux, how to tell how many cores of the machine are active? I assume a test for this would work for Android too.
I need to know if more than one core is ever active. Was wondering to test this by having a process create many threads. Is it possible for a thread to query which processor it is on? that way one can tell if multiple cores will ever be used under heavy load. Not sure if I am on the right track.










share|improve this question













migrated from stackoverflow.com Jan 25 '11 at 3:17


This question came from our site for professional and enthusiast programmers.



















  • By "active", I assume you mean how many cores are currently in use? Or do you mean how many cores the system has?

    – Mikel
    Jan 24 '11 at 22:40











  • yes, I would like to tell how many are currently in use

    – Anil
    Jan 24 '11 at 22:43
















12















On Linux, how to tell how many cores of the machine are active? I assume a test for this would work for Android too.
I need to know if more than one core is ever active. Was wondering to test this by having a process create many threads. Is it possible for a thread to query which processor it is on? that way one can tell if multiple cores will ever be used under heavy load. Not sure if I am on the right track.










share|improve this question













migrated from stackoverflow.com Jan 25 '11 at 3:17


This question came from our site for professional and enthusiast programmers.



















  • By "active", I assume you mean how many cores are currently in use? Or do you mean how many cores the system has?

    – Mikel
    Jan 24 '11 at 22:40











  • yes, I would like to tell how many are currently in use

    – Anil
    Jan 24 '11 at 22:43














12












12








12


2






On Linux, how to tell how many cores of the machine are active? I assume a test for this would work for Android too.
I need to know if more than one core is ever active. Was wondering to test this by having a process create many threads. Is it possible for a thread to query which processor it is on? that way one can tell if multiple cores will ever be used under heavy load. Not sure if I am on the right track.










share|improve this question














On Linux, how to tell how many cores of the machine are active? I assume a test for this would work for Android too.
I need to know if more than one core is ever active. Was wondering to test this by having a process create many threads. Is it possible for a thread to query which processor it is on? that way one can tell if multiple cores will ever be used under heavy load. Not sure if I am on the right track.







linux core






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 24 '11 at 22:32









likejudolikejudo

166115




166115




migrated from stackoverflow.com Jan 25 '11 at 3:17


This question came from our site for professional and enthusiast programmers.









migrated from stackoverflow.com Jan 25 '11 at 3:17


This question came from our site for professional and enthusiast programmers.















  • By "active", I assume you mean how many cores are currently in use? Or do you mean how many cores the system has?

    – Mikel
    Jan 24 '11 at 22:40











  • yes, I would like to tell how many are currently in use

    – Anil
    Jan 24 '11 at 22:43



















  • By "active", I assume you mean how many cores are currently in use? Or do you mean how many cores the system has?

    – Mikel
    Jan 24 '11 at 22:40











  • yes, I would like to tell how many are currently in use

    – Anil
    Jan 24 '11 at 22:43

















By "active", I assume you mean how many cores are currently in use? Or do you mean how many cores the system has?

– Mikel
Jan 24 '11 at 22:40





By "active", I assume you mean how many cores are currently in use? Or do you mean how many cores the system has?

– Mikel
Jan 24 '11 at 22:40













yes, I would like to tell how many are currently in use

– Anil
Jan 24 '11 at 22:43





yes, I would like to tell how many are currently in use

– Anil
Jan 24 '11 at 22:43










5 Answers
5






active

oldest

votes


















17














You can use top to list the utilization of each core. Press 1 if necessary to split the CPU row into a separate row for each core.



You can also add a column that shows the last-used core for each process. Press f to bring up the field list, then j to activate the "P" column. Then press space to return to the live view.






share|improve this answer
























  • So perhaps I should write and run a program that spawns many threads and then run the 'top' command in the console?

    – likejudo
    Jan 25 '11 at 17:36











  • I think that should work. Just press H when you're in top to list threads separately. Or you could write a program with an infinite loop and run it a bunch of times.

    – Brian
    Jan 25 '11 at 21:00











  • Say, I write the program to spawn 100 threads, each one performing some long, intensive computation. If I write it in Java (Android), is there a guarantee that the JVM/KVM will run the threads on different cores, and run them on all the cores?

    – likejudo
    Jan 25 '11 at 22:15








  • 1





    I don't know - isn't that what your experiment is supposed to figure out?

    – Brian
    Jan 25 '11 at 22:28











  • I need to test a program that says it will restrict the number of processor cores being used. I shall search some more. thanks!

    – likejudo
    Jan 25 '11 at 23:37



















6














ps has a field called psr to tell you which processor a job is running on.



So you could use something like:



ps -e -o psr= | sort | uniq | wc -l




Note that merely running ps like this will of course make at least one core active.



Probably better is to run this:



tmp=/tmp/ps.$$
ps -e -o psr= > /tmp/ps.$$
sort -u "$tmp" | wc -l
rm "$tmp"


that way the sort and wc do not increase the count.






share|improve this answer
























  • What if system has 16 cores and nobody is using some of them?

    – Elalfer
    Jan 24 '11 at 22:44











  • Then it prints 0 because none of them are in use. I think that is what the question is asking for.

    – Mikel
    Jan 24 '11 at 22:45











  • Didn't see new comments to the question.

    – Elalfer
    Jan 24 '11 at 22:47






  • 1





    Of course, by running ps we are making at least 1 core active. ;-)

    – Mikel
    Jan 24 '11 at 22:51











  • Thanks for your answer. The disadvantage is I need to know if more than one core is ever active. Was wondering to test this by having a process create many threads. Is it possible for a thread to query which processor it is on? that way one can tell if multiple cores will ever be used under heavy load. Not sure if I am on the right track.

    – Anil
    Jan 24 '11 at 22:57



















2














Try the following:



cat /proc/cpuinfo


Here's a link to an Android Java example.






share|improve this answer



















  • 1





    By "active", I assume Anil means how many cores are currently in use, and how many are idle, i.e. an approximation of how busy the system is. /proc/cpuinfo just tells you how many cores the system has, and even you would have to do more than cat /proc/cpuinfo to account for HyperThreading.

    – Mikel
    Jan 24 '11 at 22:38











  • OK - that wasn't clear but you're right.

    – Amir Afghani
    Jan 24 '11 at 22:49



















2














htop


This command works good in both ubuntu and centos and shows graphically how many CPUs and how are they being used.



for centos:



yum install htop


for ubuntu:



apt-get install htop





share|improve this answer































    0














    You can use cat /sys/devices/system/cpu/possible or cat /sys/devices/system/cpu/online. Possible is mainly incase you have isolated a cpu to run some particular program.






    share|improve this answer
























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f237413%2fon-linux-how-to-tell-how-many-cores-of-the-machine-are-active%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      17














      You can use top to list the utilization of each core. Press 1 if necessary to split the CPU row into a separate row for each core.



      You can also add a column that shows the last-used core for each process. Press f to bring up the field list, then j to activate the "P" column. Then press space to return to the live view.






      share|improve this answer
























      • So perhaps I should write and run a program that spawns many threads and then run the 'top' command in the console?

        – likejudo
        Jan 25 '11 at 17:36











      • I think that should work. Just press H when you're in top to list threads separately. Or you could write a program with an infinite loop and run it a bunch of times.

        – Brian
        Jan 25 '11 at 21:00











      • Say, I write the program to spawn 100 threads, each one performing some long, intensive computation. If I write it in Java (Android), is there a guarantee that the JVM/KVM will run the threads on different cores, and run them on all the cores?

        – likejudo
        Jan 25 '11 at 22:15








      • 1





        I don't know - isn't that what your experiment is supposed to figure out?

        – Brian
        Jan 25 '11 at 22:28











      • I need to test a program that says it will restrict the number of processor cores being used. I shall search some more. thanks!

        – likejudo
        Jan 25 '11 at 23:37
















      17














      You can use top to list the utilization of each core. Press 1 if necessary to split the CPU row into a separate row for each core.



      You can also add a column that shows the last-used core for each process. Press f to bring up the field list, then j to activate the "P" column. Then press space to return to the live view.






      share|improve this answer
























      • So perhaps I should write and run a program that spawns many threads and then run the 'top' command in the console?

        – likejudo
        Jan 25 '11 at 17:36











      • I think that should work. Just press H when you're in top to list threads separately. Or you could write a program with an infinite loop and run it a bunch of times.

        – Brian
        Jan 25 '11 at 21:00











      • Say, I write the program to spawn 100 threads, each one performing some long, intensive computation. If I write it in Java (Android), is there a guarantee that the JVM/KVM will run the threads on different cores, and run them on all the cores?

        – likejudo
        Jan 25 '11 at 22:15








      • 1





        I don't know - isn't that what your experiment is supposed to figure out?

        – Brian
        Jan 25 '11 at 22:28











      • I need to test a program that says it will restrict the number of processor cores being used. I shall search some more. thanks!

        – likejudo
        Jan 25 '11 at 23:37














      17












      17








      17







      You can use top to list the utilization of each core. Press 1 if necessary to split the CPU row into a separate row for each core.



      You can also add a column that shows the last-used core for each process. Press f to bring up the field list, then j to activate the "P" column. Then press space to return to the live view.






      share|improve this answer













      You can use top to list the utilization of each core. Press 1 if necessary to split the CPU row into a separate row for each core.



      You can also add a column that shows the last-used core for each process. Press f to bring up the field list, then j to activate the "P" column. Then press space to return to the live view.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Jan 25 '11 at 3:38









      BrianBrian

      909519




      909519













      • So perhaps I should write and run a program that spawns many threads and then run the 'top' command in the console?

        – likejudo
        Jan 25 '11 at 17:36











      • I think that should work. Just press H when you're in top to list threads separately. Or you could write a program with an infinite loop and run it a bunch of times.

        – Brian
        Jan 25 '11 at 21:00











      • Say, I write the program to spawn 100 threads, each one performing some long, intensive computation. If I write it in Java (Android), is there a guarantee that the JVM/KVM will run the threads on different cores, and run them on all the cores?

        – likejudo
        Jan 25 '11 at 22:15








      • 1





        I don't know - isn't that what your experiment is supposed to figure out?

        – Brian
        Jan 25 '11 at 22:28











      • I need to test a program that says it will restrict the number of processor cores being used. I shall search some more. thanks!

        – likejudo
        Jan 25 '11 at 23:37



















      • So perhaps I should write and run a program that spawns many threads and then run the 'top' command in the console?

        – likejudo
        Jan 25 '11 at 17:36











      • I think that should work. Just press H when you're in top to list threads separately. Or you could write a program with an infinite loop and run it a bunch of times.

        – Brian
        Jan 25 '11 at 21:00











      • Say, I write the program to spawn 100 threads, each one performing some long, intensive computation. If I write it in Java (Android), is there a guarantee that the JVM/KVM will run the threads on different cores, and run them on all the cores?

        – likejudo
        Jan 25 '11 at 22:15








      • 1





        I don't know - isn't that what your experiment is supposed to figure out?

        – Brian
        Jan 25 '11 at 22:28











      • I need to test a program that says it will restrict the number of processor cores being used. I shall search some more. thanks!

        – likejudo
        Jan 25 '11 at 23:37

















      So perhaps I should write and run a program that spawns many threads and then run the 'top' command in the console?

      – likejudo
      Jan 25 '11 at 17:36





      So perhaps I should write and run a program that spawns many threads and then run the 'top' command in the console?

      – likejudo
      Jan 25 '11 at 17:36













      I think that should work. Just press H when you're in top to list threads separately. Or you could write a program with an infinite loop and run it a bunch of times.

      – Brian
      Jan 25 '11 at 21:00





      I think that should work. Just press H when you're in top to list threads separately. Or you could write a program with an infinite loop and run it a bunch of times.

      – Brian
      Jan 25 '11 at 21:00













      Say, I write the program to spawn 100 threads, each one performing some long, intensive computation. If I write it in Java (Android), is there a guarantee that the JVM/KVM will run the threads on different cores, and run them on all the cores?

      – likejudo
      Jan 25 '11 at 22:15







      Say, I write the program to spawn 100 threads, each one performing some long, intensive computation. If I write it in Java (Android), is there a guarantee that the JVM/KVM will run the threads on different cores, and run them on all the cores?

      – likejudo
      Jan 25 '11 at 22:15






      1




      1





      I don't know - isn't that what your experiment is supposed to figure out?

      – Brian
      Jan 25 '11 at 22:28





      I don't know - isn't that what your experiment is supposed to figure out?

      – Brian
      Jan 25 '11 at 22:28













      I need to test a program that says it will restrict the number of processor cores being used. I shall search some more. thanks!

      – likejudo
      Jan 25 '11 at 23:37





      I need to test a program that says it will restrict the number of processor cores being used. I shall search some more. thanks!

      – likejudo
      Jan 25 '11 at 23:37













      6














      ps has a field called psr to tell you which processor a job is running on.



      So you could use something like:



      ps -e -o psr= | sort | uniq | wc -l




      Note that merely running ps like this will of course make at least one core active.



      Probably better is to run this:



      tmp=/tmp/ps.$$
      ps -e -o psr= > /tmp/ps.$$
      sort -u "$tmp" | wc -l
      rm "$tmp"


      that way the sort and wc do not increase the count.






      share|improve this answer
























      • What if system has 16 cores and nobody is using some of them?

        – Elalfer
        Jan 24 '11 at 22:44











      • Then it prints 0 because none of them are in use. I think that is what the question is asking for.

        – Mikel
        Jan 24 '11 at 22:45











      • Didn't see new comments to the question.

        – Elalfer
        Jan 24 '11 at 22:47






      • 1





        Of course, by running ps we are making at least 1 core active. ;-)

        – Mikel
        Jan 24 '11 at 22:51











      • Thanks for your answer. The disadvantage is I need to know if more than one core is ever active. Was wondering to test this by having a process create many threads. Is it possible for a thread to query which processor it is on? that way one can tell if multiple cores will ever be used under heavy load. Not sure if I am on the right track.

        – Anil
        Jan 24 '11 at 22:57
















      6














      ps has a field called psr to tell you which processor a job is running on.



      So you could use something like:



      ps -e -o psr= | sort | uniq | wc -l




      Note that merely running ps like this will of course make at least one core active.



      Probably better is to run this:



      tmp=/tmp/ps.$$
      ps -e -o psr= > /tmp/ps.$$
      sort -u "$tmp" | wc -l
      rm "$tmp"


      that way the sort and wc do not increase the count.






      share|improve this answer
























      • What if system has 16 cores and nobody is using some of them?

        – Elalfer
        Jan 24 '11 at 22:44











      • Then it prints 0 because none of them are in use. I think that is what the question is asking for.

        – Mikel
        Jan 24 '11 at 22:45











      • Didn't see new comments to the question.

        – Elalfer
        Jan 24 '11 at 22:47






      • 1





        Of course, by running ps we are making at least 1 core active. ;-)

        – Mikel
        Jan 24 '11 at 22:51











      • Thanks for your answer. The disadvantage is I need to know if more than one core is ever active. Was wondering to test this by having a process create many threads. Is it possible for a thread to query which processor it is on? that way one can tell if multiple cores will ever be used under heavy load. Not sure if I am on the right track.

        – Anil
        Jan 24 '11 at 22:57














      6












      6








      6







      ps has a field called psr to tell you which processor a job is running on.



      So you could use something like:



      ps -e -o psr= | sort | uniq | wc -l




      Note that merely running ps like this will of course make at least one core active.



      Probably better is to run this:



      tmp=/tmp/ps.$$
      ps -e -o psr= > /tmp/ps.$$
      sort -u "$tmp" | wc -l
      rm "$tmp"


      that way the sort and wc do not increase the count.






      share|improve this answer













      ps has a field called psr to tell you which processor a job is running on.



      So you could use something like:



      ps -e -o psr= | sort | uniq | wc -l




      Note that merely running ps like this will of course make at least one core active.



      Probably better is to run this:



      tmp=/tmp/ps.$$
      ps -e -o psr= > /tmp/ps.$$
      sort -u "$tmp" | wc -l
      rm "$tmp"


      that way the sort and wc do not increase the count.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Jan 24 '11 at 22:34









      MikelMikel

      7,58913435




      7,58913435













      • What if system has 16 cores and nobody is using some of them?

        – Elalfer
        Jan 24 '11 at 22:44











      • Then it prints 0 because none of them are in use. I think that is what the question is asking for.

        – Mikel
        Jan 24 '11 at 22:45











      • Didn't see new comments to the question.

        – Elalfer
        Jan 24 '11 at 22:47






      • 1





        Of course, by running ps we are making at least 1 core active. ;-)

        – Mikel
        Jan 24 '11 at 22:51











      • Thanks for your answer. The disadvantage is I need to know if more than one core is ever active. Was wondering to test this by having a process create many threads. Is it possible for a thread to query which processor it is on? that way one can tell if multiple cores will ever be used under heavy load. Not sure if I am on the right track.

        – Anil
        Jan 24 '11 at 22:57



















      • What if system has 16 cores and nobody is using some of them?

        – Elalfer
        Jan 24 '11 at 22:44











      • Then it prints 0 because none of them are in use. I think that is what the question is asking for.

        – Mikel
        Jan 24 '11 at 22:45











      • Didn't see new comments to the question.

        – Elalfer
        Jan 24 '11 at 22:47






      • 1





        Of course, by running ps we are making at least 1 core active. ;-)

        – Mikel
        Jan 24 '11 at 22:51











      • Thanks for your answer. The disadvantage is I need to know if more than one core is ever active. Was wondering to test this by having a process create many threads. Is it possible for a thread to query which processor it is on? that way one can tell if multiple cores will ever be used under heavy load. Not sure if I am on the right track.

        – Anil
        Jan 24 '11 at 22:57

















      What if system has 16 cores and nobody is using some of them?

      – Elalfer
      Jan 24 '11 at 22:44





      What if system has 16 cores and nobody is using some of them?

      – Elalfer
      Jan 24 '11 at 22:44













      Then it prints 0 because none of them are in use. I think that is what the question is asking for.

      – Mikel
      Jan 24 '11 at 22:45





      Then it prints 0 because none of them are in use. I think that is what the question is asking for.

      – Mikel
      Jan 24 '11 at 22:45













      Didn't see new comments to the question.

      – Elalfer
      Jan 24 '11 at 22:47





      Didn't see new comments to the question.

      – Elalfer
      Jan 24 '11 at 22:47




      1




      1





      Of course, by running ps we are making at least 1 core active. ;-)

      – Mikel
      Jan 24 '11 at 22:51





      Of course, by running ps we are making at least 1 core active. ;-)

      – Mikel
      Jan 24 '11 at 22:51













      Thanks for your answer. The disadvantage is I need to know if more than one core is ever active. Was wondering to test this by having a process create many threads. Is it possible for a thread to query which processor it is on? that way one can tell if multiple cores will ever be used under heavy load. Not sure if I am on the right track.

      – Anil
      Jan 24 '11 at 22:57





      Thanks for your answer. The disadvantage is I need to know if more than one core is ever active. Was wondering to test this by having a process create many threads. Is it possible for a thread to query which processor it is on? that way one can tell if multiple cores will ever be used under heavy load. Not sure if I am on the right track.

      – Anil
      Jan 24 '11 at 22:57











      2














      Try the following:



      cat /proc/cpuinfo


      Here's a link to an Android Java example.






      share|improve this answer



















      • 1





        By "active", I assume Anil means how many cores are currently in use, and how many are idle, i.e. an approximation of how busy the system is. /proc/cpuinfo just tells you how many cores the system has, and even you would have to do more than cat /proc/cpuinfo to account for HyperThreading.

        – Mikel
        Jan 24 '11 at 22:38











      • OK - that wasn't clear but you're right.

        – Amir Afghani
        Jan 24 '11 at 22:49
















      2














      Try the following:



      cat /proc/cpuinfo


      Here's a link to an Android Java example.






      share|improve this answer



















      • 1





        By "active", I assume Anil means how many cores are currently in use, and how many are idle, i.e. an approximation of how busy the system is. /proc/cpuinfo just tells you how many cores the system has, and even you would have to do more than cat /proc/cpuinfo to account for HyperThreading.

        – Mikel
        Jan 24 '11 at 22:38











      • OK - that wasn't clear but you're right.

        – Amir Afghani
        Jan 24 '11 at 22:49














      2












      2








      2







      Try the following:



      cat /proc/cpuinfo


      Here's a link to an Android Java example.






      share|improve this answer













      Try the following:



      cat /proc/cpuinfo


      Here's a link to an Android Java example.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Jan 24 '11 at 22:34









      Amir AfghaniAmir Afghani

      248138




      248138








      • 1





        By "active", I assume Anil means how many cores are currently in use, and how many are idle, i.e. an approximation of how busy the system is. /proc/cpuinfo just tells you how many cores the system has, and even you would have to do more than cat /proc/cpuinfo to account for HyperThreading.

        – Mikel
        Jan 24 '11 at 22:38











      • OK - that wasn't clear but you're right.

        – Amir Afghani
        Jan 24 '11 at 22:49














      • 1





        By "active", I assume Anil means how many cores are currently in use, and how many are idle, i.e. an approximation of how busy the system is. /proc/cpuinfo just tells you how many cores the system has, and even you would have to do more than cat /proc/cpuinfo to account for HyperThreading.

        – Mikel
        Jan 24 '11 at 22:38











      • OK - that wasn't clear but you're right.

        – Amir Afghani
        Jan 24 '11 at 22:49








      1




      1





      By "active", I assume Anil means how many cores are currently in use, and how many are idle, i.e. an approximation of how busy the system is. /proc/cpuinfo just tells you how many cores the system has, and even you would have to do more than cat /proc/cpuinfo to account for HyperThreading.

      – Mikel
      Jan 24 '11 at 22:38





      By "active", I assume Anil means how many cores are currently in use, and how many are idle, i.e. an approximation of how busy the system is. /proc/cpuinfo just tells you how many cores the system has, and even you would have to do more than cat /proc/cpuinfo to account for HyperThreading.

      – Mikel
      Jan 24 '11 at 22:38













      OK - that wasn't clear but you're right.

      – Amir Afghani
      Jan 24 '11 at 22:49





      OK - that wasn't clear but you're right.

      – Amir Afghani
      Jan 24 '11 at 22:49











      2














      htop


      This command works good in both ubuntu and centos and shows graphically how many CPUs and how are they being used.



      for centos:



      yum install htop


      for ubuntu:



      apt-get install htop





      share|improve this answer




























        2














        htop


        This command works good in both ubuntu and centos and shows graphically how many CPUs and how are they being used.



        for centos:



        yum install htop


        for ubuntu:



        apt-get install htop





        share|improve this answer


























          2












          2








          2







          htop


          This command works good in both ubuntu and centos and shows graphically how many CPUs and how are they being used.



          for centos:



          yum install htop


          for ubuntu:



          apt-get install htop





          share|improve this answer













          htop


          This command works good in both ubuntu and centos and shows graphically how many CPUs and how are they being used.



          for centos:



          yum install htop


          for ubuntu:



          apt-get install htop






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 21 '16 at 15:44









          Srihari KaranthSrihari Karanth

          1212




          1212























              0














              You can use cat /sys/devices/system/cpu/possible or cat /sys/devices/system/cpu/online. Possible is mainly incase you have isolated a cpu to run some particular program.






              share|improve this answer




























                0














                You can use cat /sys/devices/system/cpu/possible or cat /sys/devices/system/cpu/online. Possible is mainly incase you have isolated a cpu to run some particular program.






                share|improve this answer


























                  0












                  0








                  0







                  You can use cat /sys/devices/system/cpu/possible or cat /sys/devices/system/cpu/online. Possible is mainly incase you have isolated a cpu to run some particular program.






                  share|improve this answer













                  You can use cat /sys/devices/system/cpu/possible or cat /sys/devices/system/cpu/online. Possible is mainly incase you have isolated a cpu to run some particular program.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Feb 28 at 14:00









                  SabsterSabster

                  11




                  11






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f237413%2fon-linux-how-to-tell-how-many-cores-of-the-machine-are-active%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      How do I know what Microsoft account the skydrive app is syncing to?

                      When does type information flow backwards in C++?

                      Grease: Live!