blog posts

How to Use Linux LSCPU Command and Get CPU Information on it

The LSCPU command, one of the attractive commands of the Linux operating system, helps you reach your goal and curiosity regarding the device’s processor structure. Suppose you are one of those people who do not understand the product’s details, structural specifications, and functional features after buying an electronic device or device. In that case, you will not feel at ease. By purchasing a computer system or desktop computer, you want to understand all the structural specifications of the device and its processors. You will stay with us for the rest of this article to introduce you.

LSCPU instruction and processor architecture or structure information

If you are using the Linux operating system on your computer, you can use the LSCPU command to get information about the structure and specifications of the processor. Information such as the CPU manufacturer, its type in terms of whether it is 32-bit or 64-bit, CPU speed, etc., can be obtained using this command.

The LSCPU command, which stands for List CPU, gathers processor architecture information from the sysfs and /proc/cpuinfo paths. The /proc path consists of various files containing all the information and hardware specifications of your computer system. Command output can be optimized for parsing or easy human readability.

This information includes, for example, the number of CPUs, threads, cores, sockets, and non-uniform memory access (NUMA) nodes. There is also information about processor cache and cache sharing, family, model, bogoMIPS, byte order, and ranking.

Options that result in an output table have a list argument. Use this argument to customize the output of the command. Specify a comma-separated list of columns to sort the output table using only specified columns. For a list of valid column labels, see the Columns section below.

Columns of LSCPU command output information

Not all columns are supported on all architectures. If the user requests a column that is not supported, the LSCPU prints the column but does not provide any data for it. It should be mentioned that column labels are not case-sensitive.

The output columns are as follows:

(CPU) processor

The result of this section is the logical number of CPUs used by the Linux kernel.

(CORE) core

This column of the LSCPU command output shows the logical number of processor cores. A core can contain multiple CPUs.

(SOCKET) Socket

In this section, the logical number of sockets is specified. A socket can contain multiple cores.

(NODE) ​​Node

The logical number of NUMA nodes on the system processor is specified in this section. A node may contain multiple books.

(CACHE) Cache memory

Information on how cache memory is shared between processors can be found in this section.

(ADDRESS) address

The address or physical specifications of the processor are given in this section.

(ONLINE) online

An indicator that shows whether the Linux system is currently using the CPU or not.

(CONFIGURED) configured

An indicator that shows whether the hypervisor (virtual machine supervisor) has allocated CPU to the virtual hardware on which the Linux instance is running or not. Processors that are configured can be configured online by the Linux instance. This column contains data only if the hardware system and hypervisor support the allocation of a dynamic CPU.

POLARIZATION

This column of the LSCPU command output contains data for Linux instances running with hypervisor-equipped virtual hardware that can change the CPU’s message-sending mode (polarization). Polarization can be in the following two modes:

(horizontal): In this mode, the workload is spread across all available processors.
Vertical: The workload is concentrated in a few CPUs in vertical mode.

This column also shows the processor’s performance rating for vertical polarization as high, medium, or low. This column will only contain data if the hardware system and hypervisor support processor polarization.

Functional and peripheral options next to the LSCPU command

In addition to the LSCPU command, you can use additional and very useful commands and options, which we will briefly mention below and explain their effect.

a, -all-

Include lines for online and offline processors in the output (defaults to e-). This option may only be specified in conjunction with the -e or -p option.

-b, -online

Limit output to online CPUs (default for -p). This option may only be specified in conjunction with the -e or -p option.

-c, –offline

Limit output to offline processors. This option may only be specified in conjunction with the -e or -p option.

e, -extended-

Display CPU information in a human-readable format. If the list argument is omitted, all columns for which data is available are included in the command output. When specifying the list argument, the option string, the equal sign (=), and the word list must not contain any blanks or other whitespace. Examples: ‘e = -CPU, node’ or ‘extended = -CPU, node’.

h, -help-

Display help information and exit.

p, -parse-

Optimize command output for easy parsing.

If the list argument is omitted, the output of the command is compatible with previous versions of LSCPU. Two commas are used to separate processor cache columns in this compatible format.

If the processor cache is not detected, the cache column is omitted.

If the list argument is used, the cache columns are separated by colons (:). When specifying the list argument, the option string, the equal sign (=), and the word list must not contain any blanks or other whitespace. Examples: ‘p = -CPU, node’ or ‘parse = -CPU, node’.

s, –sysroot-

Collect CPU data for an instance of Linux other than the instance from which the LSCPU command is issued. The specified directory is the root of the Linux sample system to be inspected.

x, -hex-

Use a hexadecimal mask for processor sets (e.g., 3*0). The default is to print collections in list format (e.g., 0.1).

-V, -version

Display version information and exit.

Bugs

A basic overview of the CPU family, its model, etc., is always based only on the first CPU. Sometimes on Xen Dom0, the kernel reports wrong information. It should be noted that the number of cores per socket in virtual hardware, etc., can be wrong.

Conclusion

This article discussed using the LSCPU command and the side and practical points related to this command. From now on, if you have a computer that uses the Linux operating system, you can see the structural specifications of the processor or CPU of the system using the LSCPU command.