Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to check how many cpu there are in linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to check several cpu in linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

In linux, you can use the grep command to view several cpu, which is used to find qualified strings in the file. When this command is used with the "/ proc/cpuinfo" file, you can query the number of cpu with the syntax of "grep-c 'processor' / proc/cpuinfo".

The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How does linux check how many cpu there are?

First of all, I'll show you the case of a CPU, which is the simplest.

The information of CPU is stored in / proc/cpuinfo, as shown in the following figure. Physical id represents the number of CPU, the number starts from 0, and cpu cores represents the number of cores. You can see that it is a 1-core CPU, that is, the number of CPU is 1.

After we know that the CPU information stores the file, we can simply use grep-c 'processor' / proc/cpuinfo to count the number of CPU.

Let's demonstrate the query of multiple CPU. Let's take a look at / proc/cpuinfo to see if the cpu information is different. It can be seen that there are 2 4-core CPU, that is, the number of CPU is 8.

Similarly, use grep-c 'processor' / proc/cpuinfo to count the number of CPU.

You can also query the number of CPU, the number of cores, and the total number of logical CPU separately as follows.

Note: total number of logical CPU = number of physical CPU * number of cores per physical CPU * number of hyperthreads

Query the number of CPU

Cat / proc/cpuinfo | grep "physical id" | sort | uniq | wc-l

Query core:

Cat / proc/cpuinfo | grep "cpu cores" | uniq

Total number of query logic CPU:

Cat / proc/cpuinfo | grep "processor" | wc-l

This is the end of the content of "how to view several cpu in linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report