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.
Sobre o autor
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).
Mais como este
Navegue por canal
Automação
Últimas novidades em automação de TI para empresas de tecnologia, equipes e ambientes
Inteligência artificial
Descubra as atualizações nas plataformas que proporcionam aos clientes executar suas cargas de trabalho de IA em qualquer ambiente
Nuvem híbrida aberta
Veja como construímos um futuro mais flexível com a nuvem híbrida
Segurança
Veja as últimas novidades sobre como reduzimos riscos em ambientes e tecnologias
Edge computing
Saiba quais são as atualizações nas plataformas que simplificam as operações na borda
Infraestrutura
Saiba o que há de mais recente na plataforma Linux empresarial líder mundial
Aplicações
Conheça nossas soluções desenvolvidas para ajudar você a superar os desafios mais complexos de aplicações
Programas originais
Veja as histórias divertidas de criadores e líderes em tecnologia empresarial
Produtos
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Red Hat Cloud Services
- Veja todos os produtos
Ferramentas
- Treinamento e certificação
- Minha conta
- Suporte ao cliente
- Recursos para desenvolvedores
- Encontre um parceiro
- Red Hat Ecosystem Catalog
- Calculadora de valor Red Hat
- Documentação
Experimente, compre, venda
Comunicação
- Contate o setor de vendas
- Fale com o Atendimento ao Cliente
- Contate o setor de treinamento
- Redes sociais
Sobre a Red Hat
A Red Hat é a líder mundial em soluções empresariais open source como Linux, nuvem, containers e Kubernetes. Fornecemos soluções robustas que facilitam o trabalho em diversas plataformas e ambientes, do datacenter principal até a borda da rede.
Selecione um idioma
Red Hat legal and privacy links
- Sobre a Red Hat
- Oportunidades de emprego
- Eventos
- Escritórios
- Fale com a Red Hat
- Blog da Red Hat
- Diversidade, equidade e inclusão
- Cool Stuff Store
- Red Hat Summit