Sometimes, you need to get information about the CPU on a machine, whether it's because you just can't remember what kind of CPU your computer has or you need a specific detail, such as the number of cores or whether it's 32- or 64-bit. Here are six ways to get that information on Linux.
[ Explore the central processing unit's components and functionality. ]
GNOME settings
If you use the GNOME desktop, you can see what kind of CPU you use in the Settings application.
First, click the Activities button in the top-left corner of the GNOME desktop and type Settings. In the Settings window that appears, click About in the left column.
[ Get the guide to installing applications on Linux. ]
KDE Kinfocenter
If you use the KDE desktop, find all the CPU information you could ever need in the KInfocenter application.
First, click the K Menu in the bottom-left corner of the KDE Plasma Desktop, and select Info Center. In the Info Center window, click Devices in the left column and then CPU.
[ Keep your most commonly used commands handy with the Linux commands cheat sheet. ]
Look at /proc/cpuinfo
While we often use the term "Linux" (or sometimes GNU+Linux) to refer to the operating system, it's a kernel first and foremost. As the binary responsible for bootstrapping your system, Linux has information about everything it's managing, including the CPU. This data is stored in the /proc
virtual filesystem in a file named cpuinfo
. It's this file that applications like KInfocenter parse to deliver data about your CPU, but you can parse it yourself, too.
$ cat /proc/cpuinfo | less
processor : 0
vendor_id : AuthenticAMD
cpu family : 25
model : 33
model name : AMD Ryzen 5 5600X 6-Core Processor
stepping : 0
microcode : 0xa201009
cpu MHz : 2200.000
cache size : 512 KB
physical id : 0
siblings : 12
core id : 0
cpu cores : 6
[...]
Try arch
If all you need to know is the architecture of your CPU, you can use the arch
command:
$ arch
x86_64
[ Keep your most frequently used commands handy with the Linux commands cheat sheet. ]
Use uname
The uname
command is usually used to print information about your kernel. Because your kernel is highly dependent on your CPU, you can extract a lot of CPU data from its output. For example, you can get the vendor of your CPU with the --hardware-platform
(-i
for short) option:
$ uname --hardware-platform
authenticAMD
You can also get the model of your CPU with the --processor
(-p
for short) option:
$ uname --processor
AMD Ryzen 5 5600X 6-Core Processor
And finally, the architecture with --machine
(-m
):
$ uname --machine
x86_64
Programming libraries
Sometimes you need CPU information within a non-interactive interface. On Linux, any command you type into an interactive terminal session can be scripted so that it's non-interactive, but sometimes you're working with more than just a simple script. There are usually libraries for obtaining that information if you're using a compiled programming language and you need to determine what architecture you're on. However, you may also be able to do some rudimentary tests to determine the architecture without importing a special library.
There are too many programming languages for me to give an example of all of them, but here's a simple example in C++ of the kind of logic you might use:
#include <iostream>
using namespace std;
int main() {
if ( SIZE_MAX == 0xFFFFFFFF ) {
cout << "32 bit";
} else if ( SIZE_MAX == 0xFFFFFFFFFFFFFFFF ) {
cout << "64 bit";
} else {
cout << "Unknown";
}
return 0;
}
This code checks SIZE_MAX to determine the potential maximum size of a variable. If it's set to 64-bit, then the CPU that compiled the code is capable of 64-bit.
That's not the only way to extract that kind of data; if you have libraries that make it even easier, you can use those.
Knowledge is power
Getting insight into what CPU you're running is a useful trick to know. It may not come up often, but it's annoying when it occurs and you're caught without the necessary information.
I've covered all the ways I could think of to get CPU information in this article, but there are many other ways I haven't thought of. How do you get CPU information on your systems? Email us at enable-sysadmin@redhat.com to let us know.
저자 소개
Seth Kenlon is a Linux geek, open source enthusiast, free culture advocate, and tabletop gamer. Between gigs in the film industry and the tech industry (not necessarily exclusive of one another), he likes to design games and hack on code (also not necessarily exclusive of one another).
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
오리지널 쇼
엔터프라이즈 기술 분야의 제작자와 리더가 전하는 흥미로운 스토리
제품
- Red Hat Enterprise Linux
- Red Hat OpenShift Enterprise
- Red Hat Ansible Automation Platform
- 클라우드 서비스
- 모든 제품 보기
툴
체험, 구매 & 영업
커뮤니케이션
Red Hat 소개
Red Hat은 Linux, 클라우드, 컨테이너, 쿠버네티스 등을 포함한 글로벌 엔터프라이즈 오픈소스 솔루션 공급업체입니다. Red Hat은 코어 데이터센터에서 네트워크 엣지에 이르기까지 다양한 플랫폼과 환경에서 기업의 업무 편의성을 높여 주는 강화된 기능의 솔루션을 제공합니다.