How to check if specific CPU features are available in Linux

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to check for specific CPU features available on your Linux system. You will explore different methods to inspect CPU information, starting with the fundamental cat /proc/cpuinfo command to view detailed CPU specifications and flags.

Following the initial inspection, you will utilize the lscpu command for a more structured overview of CPU architecture and capabilities. Finally, you will delve into hardware details using dmidecode to gain further insights into your system's components, including CPU information.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("Linux")) -.-> linux/BasicFileOperationsGroup(["Basic File Operations"]) linux(("Linux")) -.-> linux/UserandGroupManagementGroup(["User and Group Management"]) linux/BasicFileOperationsGroup -.-> linux/cat("File Concatenating") linux/UserandGroupManagementGroup -.-> linux/sudo("Privilege Granting") subgraph Lab Skills linux/cat -.-> lab-558803{{"How to check if specific CPU features are available in Linux"}} linux/sudo -.-> lab-558803{{"How to check if specific CPU features are available in Linux"}} end

List CPU features with cat /proc/cpuinfo

In this step, you will learn how to inspect the CPU information of your Linux system using the cat command and the /proc/cpuinfo file.

The /proc filesystem is a virtual filesystem in Linux that provides information about processes and other system information. The /proc/cpuinfo file contains details about the CPU(s) installed in your system.

The cat command is a fundamental Linux utility used to display the content of files.

Open your terminal if it's not already open. You can do this by clicking the Xfce Terminal icon on the left side of your desktop.

Now, type the following command to display the contents of the /proc/cpuinfo file:

cat /proc/cpuinfo

Press Enter.

You will see a lot of output, detailing various aspects of your CPU. The output will look similar to this (parts of the output are omitted for brevity and generality):

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 158
model name      : Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
stepping        : 9
microcode       : 0x...
cpu MHz         : ...
cache size      : ... KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : ...
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase bmi1 hle avx2 smep bmi2 erms rtm invpcid mpx rdseed adx smap clflushopt xsaves xsaveopt pcpe bts md_clear flush_l1d arch_capabilities
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit srbds mmio_stale_data retbleed
bogomips        : ...
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
...

This file provides detailed information about each CPU core, including its vendor, model name, speed, cache size, and supported features (listed under flags).

Understanding the output of /proc/cpuinfo is helpful for troubleshooting and understanding the capabilities of your system's hardware.

Click Continue to proceed to the next step.

Verify features with lscpu

In the previous step, you used cat /proc/cpuinfo to view detailed CPU information. While /proc/cpuinfo is comprehensive, the output can be quite verbose and sometimes difficult to parse quickly.

A more user-friendly command for getting a summary of CPU architecture information is lscpu. The lscpu command gathers CPU architecture information from /proc/cpuinfo and presents it in a well-formatted, human-readable output.

Let's use the lscpu command to get a summary of your CPU.

Type the following command in your terminal:

lscpu

Press Enter.

You will see a concise summary of your CPU's architecture. The output will look similar to this:

Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         39 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  1
  On-line CPU(s) list:   0
Vendor ID:               GenuineIntel
  Model name:            Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase bmi1 hle avx2 smep bmi2 erms rtm invpcid mpx rdseed adx smap clflushopt xsaves xsaveopt pcpe bts md_clear flush_l1d arch_capabilities
L1d cache:               32K
L1i cache:               32K
L2 cache:                256K
L3 cache:                6M
NUMA node(s):            1
  NUMA node0 CPU(s):     0
Vulnerability Itlb multihit:  KVM: Mitigation: VMX disabled
Vulnerability L1tf:      Mitigation: PTE Inversion; VMX conditional cache flushes, SMT disabled
Vulnerability Mds:       Mitigation: Clear CPU buffers; SMT disabled
Vulnerability Meltdown:  Mitigation: PTI
Vulnerability Mmio stale data: Mitigation: Clear CPU buffers; SMT disabled
Vulnerability Retbleed:  Mitigation: IBPB conditional, IBRS_FW, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Spec store bypass: Mitigation: Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:  Mitigation: Invalidate IBPB conditional, INDIR branch predictor by IBPB_FW, STIBP disabled
Vulnerability Spectre v2:  Mitigation: IBPB conditional, IBRS_FW, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:     Mitigation: Microcode
Vulnerability Tsx async abort: Not affected

Notice how lscpu presents the information in a structured format, making it easier to find specific details like the architecture, CPU op-modes, vendor ID, model name, and a summary of flags (CPU features).

While cat /proc/cpuinfo gives you the raw data, lscpu provides a parsed and organized view, which is often more convenient for a quick overview.

Click Continue to move on to the next step.

Inspect hardware with dmidecode

In the previous steps, you explored CPU information using cat /proc/cpuinfo and lscpu. Now, let's look at a more general tool for inspecting your system's hardware: dmidecode.

dmidecode is a tool that reads a computer's DMI (Desktop Management Interface) or SMBIOS (System Management BIOS) table. This table contains information about the system's hardware components, such as the motherboard, BIOS, memory, and more.

Because dmidecode accesses low-level system information, it requires root privileges. You can use the sudo command to run dmidecode with these privileges. Remember, the labex user has sudo access without needing a password in this environment.

Type the following command in your terminal to display the full DMI information:

sudo dmidecode

Press Enter.

You will see a large amount of output, detailing various hardware components. The output is structured into different "handles" or sections, each describing a specific part of the system (e.g., BIOS Information, System Information, Baseboard Information, Memory Device).

Here's a snippet of what you might see (output will vary depending on the virtual machine's configuration):

## dmidecode 3.3
Getting SMBIOS data from sysfs.
SMBIOS 3.3.0 present.

Handle 0x0000, DMI type 0, 26 bytes
BIOS Information
        Vendor: Google
        Version: Google
        Release Date: 01/01/2011
        Address: 0xE8000
        Runtime Size: 96 kB
        ROM Size: 128 kB
        Characteristics:
                PCI is supported
                BIOS is upgradeable
                BIOS shadowing is allowed
                Boot from CD is supported
                Selectable boot is supported
                BIOS ROM is socketed
                EDD is supported
                5.25" / 1.2MB floppy services are supported (int 13h)
                3.5" / 720kB floppy services are supported (int 13h)
                3.5" / 2.88MB floppy services are supported (int 13h)
                Print screen service is supported (int 5h)
                8042 keyboard services are supported (int 9h)
                Serial services are supported (int 14h)
                Printer services are supported (int 17h)
                CGA/mono video services are supported (int 10h)
                NEC PC-98
                ACPI is supported
                USB legacy is supported
                BIOS boot specification is supported
                Targeted content distribution is supported
                UEFI is supported
        BIOS Revision: 0.0

Handle 0x0001, DMI type 1, 27 bytes
System Information
        Manufacturer: Google
        Product Name: Google Compute Engine
        Version: pc-i440fx-xenial
        Serial Number: ...
        UUID: ...
        Wake-up Type: Power Switch
        SKU Number: ...
        Family: Virtual Machine

Handle 0x0002, DMI type 2, 10 bytes
Baseboard Information
        Manufacturer: Google
        Product Name: Google Compute Engine
        Version: pc-i440fx-xenial
        Serial Number: ...
        Asset Tag: No Asset Tag
        Features:
                Board is a hosting board
                Board is replaceable
        Location In Chassis: Not Specified
        Chassis Handle: 0x0003
        Type: Motherboard
        Contained Object Handles: 0

... (more output)

You can also specify the type of information you want to see using the -t option. For example, to see only memory information:

sudo dmidecode -t memory

Press Enter.

This will filter the output to show only details related to the system's memory devices.

dmidecode is a powerful tool for gathering detailed hardware specifications without opening the computer. It's particularly useful for inventorying hardware or troubleshooting hardware-related issues.

Click Continue to complete this lab.

Summary

In this lab, you learned how to check for specific CPU features in Linux. You began by using the cat command to display the detailed CPU information contained within the /proc/cpuinfo virtual file, which provides a comprehensive list of CPU characteristics and supported flags. This initial step introduced you to accessing system information through the /proc filesystem.