Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
If I understand correctly, Windows licensing does not consider hyperthreading as increasing the number of cores, while the rest of the OS does treat hyperthreading as if it doubled the number of cores.
Consider a system with two physical CPU's, each of which has two cores, each of which is hyperthreaded. You will see 8 cores in Windows task manager or in top on Linux. A simplistic count of output from /proc/cpuinfo will also see 8 cores. If you parse /proc/cpuinfo output more carefully, you can see there are only 4 cores.
So first decide what exactly you want to count, then decide how to count it.
I want to count the number of cores, regardless of hyperthreading.
That's actually an unclear answer to the question. But I think you mean that on a system with N actual cores, that because of hyperthreading appears to have 2*N cores, you want the answer N.
Most simple ways to count cores would give you 2*N. So if that isn't the answer you want, you should include a hyperthreaded system in your testing.
I was waiting until tomorrow when I could test this on a box at work.
For licensing, I would think you want something that works across a wide range of systems (don't depend on packages that might not be installed or on dmesg state that is only available if there has been little activity since boot, etc.) and is moderately resistant to tampering.
For all that, I don't know a reasonable choice other than writing your own program to read and parse /proc/cpuinfo and understand a few different forms of the info that could appear there.
I found this command in one of the blogs and it works well.
Below Commands can be used to check Logical CPU's and need to check with the result of above command to check to see if hyper threading is enabled or not.
$ grep -c processor /proc/cpuinfo # Give the number of Logical CPU's
$ nproc # Give the number of Logical CPU's , CentOS v6+
$ lscpu | grep "CPU(s):" # Give the number of Logical CPU's more detailed , CentOS v6+
I need a one line command to count number of cores in all processers.
My lappy is 8 core mechine (4 duel core processers) and i can see that 2 cores in each and every prcessor.
But my requirement is to get total number of cores with one line command.
Is there anything as such?