In Linux, “/proc
” is a special virtual file system that contains valuable system-related information in different files. Such a file is “/proc/cpuinfo
“, which stores detailed information about the CPU, such as vendor ID, CPU family, model name, virtualization features, caches, and many more.
Since it’s a read-only file, you can’t modify it, but you can use the “cat
” or “bat
” command to view its contents.
$ cat /proc/cpuinfo
Output:
This file provides much more CPU information compared to other built-in or external tools. If you are familiar with specific fields in this file, you can use other tools such as “grep
” or “cut
” to extract information from that field, which you can then use in a command or shell script.
For example, the file mentions the CPU model name multiple times, which I want to extract. The condition is that the output should contain only one occurence, disregarding all others. For this purpose, you can use the following command:
$ cat /proc/cpuinfo | grep "model name" | uniq
The above command will search for the “model name” field using the “grep
” command and then retain only one occurrence using “uniq
” command.
Alternatively, if you only want to output the “model name” value without the field name, you can use the “cut
” command for that purpose.
$ cat /proc/cpuinfo | grep "model name" | uniq | cut -d " " -f 3-
The command above will function almost identically to the previous one, except it will output only the third and subsequent fields, omitting the previous two.
This way, you can use the information from “/proc/cpuinfo
” in a command or shell script. Now, most of the fields are named in a manner that allows anyone to readily identify and understand the value they represent, except for the flags.
Flags in the /proc/cpuinfo File
The “flags
” field in the “/proc/cpuinfo
” file contains various flags that define the number of processors attribute. So, let’s see some of the most important flags and understand what information they provide.
Flag | Description |
---|---|
fpu | Indicates the presence of a floating-point unit. |
vme | Virtual 8086 mode enhancements. |
de | Debugging extensions. |
pse | Page size extensions. |
tsc | Time stamp counter. |
msr | Model-specific registers. |
pae | Physical address extensions. |
mce | Machine check exception. |
apic | Advanced Programmable Interrupt Controller. |
sep | Fast system call. |
pge | Page global enable. |
mca | Machine check architecture. |
pat | Page attribute table. |
clflush | Cache line flush instruction. |
mmx | Multimedia extensions. |
sse | Streaming SIMD Extensions. |
sse2 | Streaming SIMD Extensions 2. |
syscall | SYSCALL and SYSRET instructions. |
lm | Long mode (64-bit support). |
constant_tsc | TSC ticks at a constant rate. |
ssse3 | Supplemental Streaming SIMD Extensions 3. |
fma | Fused multiply-add. |
pcid | Process-context identifiers. |
sse4_1 | Streaming SIMD Extensions 4.1. |
sse4_2 | Streaming SIMD Extensions 4.2. |
avx | Advanced Vector Extensions. |
f16c | 16-bit floating-point conversion instructions. |
hypervisor | Indicates the system is running under a hypervisor. |
The above are a few of the many flags. For a comprehensive list of all flags, along with links for further understanding, refer to this Stack Exchange answer.
Final Word
This article has come to an end. I hope you learned and understood more about the “/etc/cpuinfo
” file in this article. If you have any questions or queries about the topic, please leave a comment.
Till then, peace!
Join The Conversation
Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.