9 Commands to Check CPU Information on Linux
The cpu information includes details about the processor, like the architecture, vendor name, model, number of cores, speed of each core etc.
There are quite a few commands on linux to get those details about the cpu.
In this post we shall take a look at some of the commonly used commands that can be used to get details about the cpu.
The /proc/cpuinfo file contains details about individual cpu cores.
Output its contents with less or cat.
Every processor or core is listed separately the various details about speed, cache size and model name are included in the description.
To count the number of processing units use grep with wc
To get the actual number of cores, check the core id for unique values
So there are 4 different core ids. This indicates that there are 4 actual cores.
2. lscpu — display information about the CPU architecture
lscpu is a small and quick command that does not need any options. It would simply print the cpu hardware details in a user-friendly format.
Hardinfo is a gtk based gui tool that generates reports about various hardware components. But it can also run from the command line only if there is no gui display available.
It would produce a large report about many hardware parts, by reading files from the /proc directory. The cpu information is towards the beginning of the report. The report can also be written to a text file.
Hardinfo also performs a few benchmark tests taking a few minutes before the report is displayed.
The lshw command can display limited information about the cpu. lshw by default shows information about various hardware parts, and the ‘-class’ option can be used to pickup information about a specific hardware part.
The vendor, model and speed of the processor are being shown correctly. However it is not possible to deduce the number of cores on the processor from the above output.
The nproc command just prints out the number of processing units available. Note that the number of processing units might not always be the same as number of cores.
The dmidecode command displays some information about the cpu, which includes the socket type, vendor name and various flags.
The cpuid command fetches CPUID information about Intel and AMD x86 processors.
The program can be installed with apt on ubuntu
And here is sample output
Inxi is a script that uses other programs to generate a well structured easy to read report about various hardware components on the system. Check out the full tutorial on inxi.
Print out cpu/processor related information
To learn more about the inxi command and its usage check out this post:
How to use «Inxi» to check Hardware Information on Linux
The hwinfo command is a hardware information program that can be used to collect details about various hardware components on a Linux system.
It also displays information about the processor. Here is a quick example:
If you don’t use the «—short» option it will display much more information about each cpu core like architecture and processor features.
To learn more about the hwinfo command check this post:
Check hardware information on Linux with «hwinfo» command
Those were some of the commands to check CPU information on Linux based systems like Ubuntu, Fedora, Debian, CentOS etc.
For some more command examples on checking cpu information check this post:
How to Check Processor and CPU Details on Linux — Command Examples
Most of the commands are command line based and show text output. For a GUI interface use the program called Hardinfo.
It shows hardware details about various components in a easy to use GUI interface.
If you know of any other useful command that can display information about the CPU, let us know in the comments below.
Very nicely explained. I highly recommend it in my articles. thank you.
Thank you for the information, i learn lot in this article. 🙂
Thanks for the Information.
Hi everybody, someone know how to get same information regarding the hardware where I installed a phisical linux ?
Thank you for sharing, it helping lot.
lshw now (DISTRIB_DESCRIPTION=”Linux Mint 17.3 Rosa”) includes a line like below at the bottom of it’s listing:
configuration: cores=4 enabledcores=4 threads=8
How to get the number of real cores, not HiperThreading.
For example, for i7, real cores are 4, but logical are 8. There is some way without root ?
check this post for commands to check the number of real cores.
are we still catting into grep?
grep ‘core id’ /proc/cpuinfo
yo Silver Moon, nice write-up bro. absolutelly useful stuff there, though the number of CPUs can be fetched using just ‘grep -c processor /proc/cpuinfo’. take care 🙂
Thank you for the helpful information. You can not look for “unique values” with the “cat /proc/cpuinfo |grep ‘core id’” command on a multiprocessor system. The situation gets even worse with hyperthreading enabled CPU’s.
How to Get CPU Info in Ubuntu
Curious about the brain of your computer? What kinds of architecture it has, and how many CPU cores it has? Who's the manufacturer? What's the model?
There are all kinds of processor information you can look for. And there are various kinds of commands and tools available for this purpose. Some of them show detailed output while some show only the essential ones.
Let me share various ways you can get processor details in Ubuntu command line.
Using lscpu command
The lscpu utility gathers CPU architecture info from sysfs and /proc/cpuinfo and can be found on most of the Linux distros.
And I use lscpu quite often with my VMs as you get few cores:
As you can see, it goes in too much details on the CPU. It tells you the architecture, number of cores, manufacturer and a lot more details that you may not be interested in.
Checking the contents of /proc/cpuinfo file
You are not obligated to use the lscpu command. After all, it reads from the /proc/cpuinfo file so why not read it directly?
It gets you info related to individual cores making it too long to read. But you can filter the results to get the relevantinfo.
To get view the vendor name:
To display model name:
To count the number of processing units:
Using dmidecode command
The dmidecode command gets the hardware info on Linux by dumping the computer's DMI (SMBIOS) table contents in a human-readable format.
While it avails users a variety of info, I will only fetch the CPU info by the given command:
Using inxi utility
The inxi is a script made for getting system info through the command line.
Though it does not come pre-installed in Ubuntu, you can easily install it.
As I'm only looking for CPU info, the intended results can be found by using -C option:
The cpuid commands will get every detail collected by CPUID instruction and can also discover the exact model of x86 CPU(s).
Ubuntu users can utilize the given command to install cpuid:
And it can be executed by:
Using lshw command
As its name suggests, the lshw utility is intended to list the hardware configuration of your system.
But I'm looking for CPU-specific details so the output can be filtered using -C option appending with CPU:
Like the lshw command that I mentioned just above, the hwinfo command also gets the hardware details including CPU (of course).
But you have to go through the manual installation as it does not come pre-installed:
To get CPU info only, you just have to pair the hwinfo command with —cpu option:
Get the Number of Cores using nproc
If you are curious to know just the number of cores present in your system, then the nproc command will do the job.
This guide was a compilation of how you can get CPU info using different utilities. And the comments section welcomes you for queries!
Basic System Commands to get CPU, Memory, and Storage details in Linux
This article will teach you how to get CPU, Memory, and storage details using Linux shell commands.
Let’s get started.
Overview of core components of a computer
A computer is any machine that can be programmed to carry out a set of algorithms and arithmetic instructions.
Whether it’s a gaming system or a home PC, the five main components that make up a typical, present-day computer include:
You can also check the complete udemy course (Linux Shell Commands for Absolute Beginners using Ubuntu 20x)Referral link
A Central Processing Unit (CPU)
A Graphics Processing Unit (GPU), also known as a video card
Random Access Memory (RAM), also known as volatile memory
Storage: Solid State Drive (SSD) or Hard Disk Drive (HDD)
Get CPU Details using lscpu command in Linux
lscpu is an essential command in Linux to learn about your CPU configuration. You can get more details about lscpu by running lscpu —help .
A command-line utility “lscpu” in Linux is used to get CPU information of the system. The “lscpu” command fetches the CPU architecture information from the “sysfs” and /proc/cpuinfo files and displays it in a terminal.
Get Memory Details using free on Linux
The Linux free command is used to get the full usage of RAM in the computer. You can get the full details of free command by running free —help .
the free command can be used with the control arguments as shown in the below picture.
This is what the output to the free command looks like in the Linux terminal.
If you want the human-readable output of the free command you can use -h the control argument along with the free .
Get Storage Details using df in Linux
The df command in Linux is used to Show information about the file system on which each FILE resides, or all file systems by default. In layman’s terms, program df aids in the retrieval of data from any hard disc or mounted device, including CD, DVD, and flash drives.
You can get the full usage details of the df command by running the following command in the Linux terminal
If you want the output in Human readable format you can use df -h command on Linux.
If you want the storage details of the current working directory in the human-readable format you can run the following command in Linux. Here . represents the current working directory.
Get Disk Usage Details using du in Linux
The du command in Linux is used to get the disk usage. And this du command will go through each and every folder recursively and get the storage details of each and every file.
In simple words the du command will Summarize disk usage of the set of files, recursively for directories. You can get the full details of the du command by running du —help .
The output of the du command will look something like the below image.
If you want only the details of the storage at the folder level without going recursively through each and every folder to get the details of the file. Then you can use the following command in Linux.
The output will look something like the following
Get the largest folders and files using du and sort on Linux
You can use du command with sort command to troubleshoot the file which is using the highest storage in the Linux file system. The way in which you can do this is by the piping output of du command to the sort command.
The output of the above file will look something like this
Understand Storage Details of Directories using du on Windows
The detailed explanation of the Storage Details of Directories using du on Windows is in the following video time stamp.
Get storage use of folders and files
You can get the storage usage of files and folders in the Linux terminal by running the following command
When you run into permission-related issues while running the above command in the Linux terminal. You can use the following command to ignore the operation not permitted message.
The output will be displayed without permission-related errors.
You can pipe the above output to the sort command to sort the output in ascending order.
Get Storage Details of larger files using find and du
You can use the find command along with du the command to get the larger file details.
You can also sort the output by the piping sort -n command to the above command.
This is how you can troubleshoot the files and folders which are consuming more amount of storage in your Linux system.
Thank you, for reading the article. If you find it valuable please follow our publication DevOps Engineering on Cloud
You can also check the complete udemy course (Linux Shell Commands for Absolute Beginners using Ubuntu 20x)Referral link
How to find the processor / chip architecture on Linux
What command should I use to find the processor / chip architecture on Linux?
6 Answers 6
To display kernel architecture: uname -p
To display extended CPU details: cat /proc/cpuinfo
In the terminal, type
which returns output like this:
To only get the architecture:
Which in this case is
I’m surprised no one suggested uname -m . On my laptop, this gives armv7l , while uname -a gives me a monstrous two lines of text.
A concise command producing information about the current machine is hostnamectl . Example output:
It gives you the most basic information about your machine. Other commands like uname , lsb_release , or lscpu return more specific information.
You could use lscpu with grep to get only architecture.
The Overflow Blog
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.9.7.43618