Obtaining essential hardware information, such as the CPU name, is a fundamental task for anyone who managing a Linux system. The CPU (Central Processing Unit) is the core component of a computer responsible for executing instructions and performing tasks. Knowing the precise model and specifications of the CPU is crucial for optimizing performance, troubleshooting compatibility issues, and understanding the capabilities of the system. This tutorial provides 2 methods how to get CPU name on Linux.
Method 1 - /proc/cpuinfo file
The /proc/cpuinfo
file contains detailed information about the CPU on the system, including the CPU name.
Run the following command in the terminal to get CPU name:
awk -F': ' '/model name/{print $2;exit}' /proc/cpuinfo
Output example:
13th Gen Intel(R) Core(TM) i9-13900KS
Let's break down the command step by step:
awk
- is a powerful pattern scanning and text processing tool.-F': '
- this option specifies the field separator. In this case, we're setting the field separator to be a colon followed by a space. This is crucial for splitting the lines into fields based on this separator./model name/
- this is a pattern to match lines that contain the textmodel name
.{print $2;exit}
- this is the action to be taken for lines that match the pattern. It prints the second field (denoted by$2
), which is the CPU model name, and then exits the processing, ensuring only the first occurrence is printed.
Method 2 - lscpu command
The lscpu
command provides information about the CPU architecture and other related information, including the CPU name.
Open a terminal and simply run:
lscpu | awk -F': *' '/Model name/{print $2}'
Let's break down this command step by step:
lscpu
- is used to display information about the CPU on the system.awk
- is a powerful pattern scanning and text processing tool.-F': *'
- this option sets the field separator to be a colon followed by zero or more spaces. It's used to split lines into fields based on this separator./Model name/
- this is a pattern to match lines that contain the textModel name
.{print $2}
- this is the action to be taken for lines that match the pattern. It prints the second field (denoted by$2
), which is the CPU model name.
Leave a Comment
Cancel reply