How to get number of main CPU/Core using Bash? (Solved)
- LazY Puppy
- Posts: 1934
- Joined: Fri 21 Nov 2014, 18:14
- Location: Germany
How to get number of main CPU/Core using Bash? (Solved)
Hi.
I need to find out how many main CPU/Core are on the mother board.
How can I do this in bash?
Thanks.
I need to find out how many main CPU/Core are on the mother board.
How can I do this in bash?
Thanks.
Last edited by LazY Puppy on Sat 19 Dec 2015, 07:25, edited 1 time in total.
RSH
"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:
No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:
"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:
No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:
I did this and got 1 (might try '..$' if more than 9)
Code: Select all
grep -r "cpu cores" /proc/cpuinfo | grep -o '.$'
- LazY Puppy
- Posts: 1934
- Joined: Fri 21 Nov 2014, 18:14
- Location: Germany
Ok.
Terminal Output:
Prozessor is: Intel(R) Core(TM)2 Duo CPU E6750 @ 2.66GHz
File /proc/cpuinfo shows processor 0 and processor 1
Processor 0 cpu cores shows 2
Processor 1 cpu cores shows 2 also
So this means the mother board has 2 CPU and each CPU has 2 cores?
So there are 4 cores, no?
Terminal Output:
Code: Select all
root# CORES=`grep -r "cpu cores" /proc/cpuinfo | grep -o '.$'`; echo $CORES
2 2
root#
File /proc/cpuinfo shows processor 0 and processor 1
Processor 0 cpu cores shows 2
Processor 1 cpu cores shows 2 also
So this means the mother board has 2 CPU and each CPU has 2 cores?
So there are 4 cores, no?
RSH
"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:
No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:
"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:
No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:
@LazY Puppy: Your E6750 has 2 cores in total, but looks like lscpu can break it down better
Actual Cores:
Threads / Virtual Cores (should double only if there's hyper-threading):
The top result seems to match with the Intel definition of a core/CPU from what I can tell
http://ark.intel.com/products/30784/Intel-Core2-Duo-Processor-E6750-4M-Cache-2_66-GHz-1333-MHz-FSB
Actual Cores:
Code: Select all
lscpu | grep -i "Core(s)" | grep -o ".$"
Code: Select all
lscpu | grep -i "CPU(s):" | grep -o ".$"
http://ark.intel.com/products/30784/Intel-Core2-Duo-Processor-E6750-4M-Cache-2_66-GHz-1333-MHz-FSB
@rufwoof: I guess each puppy has it's own /proc/cpuinfo ? Never tried rdp so your guess is probably better than mineCores is a hardware term that describes the number of independent central processing units in a single computing component (die or chip).
- LazY Puppy
- Posts: 1934
- Joined: Fri 21 Nov 2014, 18:14
- Location: Germany
Solved
Thanks to everyone for the replies.
Marked as solved.
Marked as solved.
RSH
"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:
No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:
"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:
No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:
cpuinfo only reflects the *capacity* of the cpu, without telling you how many cores are actually being used. This:
The last two commands are the most telling.
Code: Select all
$ ls /sys/devices/system/cpu/
cpu0 cpufreq kernel_max offline possible present release
cpu1 cpuidle modalias online power probe uevent
$ cat /sys/devices/system/cpu/kernel_max
255
$ cat /sys/devices/system/cpu/offline
2-63
$ cat /sys/devices/system/cpu/possible
0-63
$ cat /sys/devices/system/cpu/present
0-1
$ cat /sys/devices/system/cpu/online
0-1
cpu frequency scaling is another way to check if the CPU is a Core or a Thread .
/sys/devices/system/cpu/cpu0/cpufreq: directory
/sys/devices/system/cpu/cpu1/cpufreq: directory
/sys/devices/system/cpu/cpu2/cpufreq: symbolic link to `../cpu0/cpufreq'
/sys/devices/system/cpu/cpu3/cpufreq: symbolic link to `../cpu1/cpufreq'
The links are for threads, directories are for cores ( I think kernel 2.6.37.4-KRG-p4_1 ) .
Code: Select all
# file /sys/devices/system/cpu/cpu[0-9]/cpufreq
/sys/devices/system/cpu/cpu1/cpufreq: directory
/sys/devices/system/cpu/cpu2/cpufreq: symbolic link to `../cpu0/cpufreq'
/sys/devices/system/cpu/cpu3/cpufreq: symbolic link to `../cpu1/cpufreq'
The links are for threads, directories are for cores ( I think kernel 2.6.37.4-KRG-p4_1 ) .