How to check if specific hardware is detected in Linux

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to check if specific hardware components are detected in a Linux environment. You will explore practical methods to gather information about your system's hardware, which is essential for troubleshooting, system administration, and understanding your computer's capabilities.

Through hands-on steps, you will use the lscpu command to examine detailed CPU information, the lspci command to list PCI devices, and inspect the /proc/devices file to understand detected hardware devices. These techniques provide valuable insights into your system's configuration and help you verify that your hardware is properly recognized by the operating system.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("Linux")) -.-> linux/BasicSystemCommandsGroup(["Basic System Commands"]) linux(("Linux")) -.-> linux/BasicFileOperationsGroup(["Basic File Operations"]) linux(("Linux")) -.-> linux/TextProcessingGroup(["Text Processing"]) linux/BasicSystemCommandsGroup -.-> linux/help("Command Assistance") linux/BasicFileOperationsGroup -.-> linux/ls("Content Listing") linux/BasicFileOperationsGroup -.-> linux/cat("File Concatenating") linux/TextProcessingGroup -.-> linux/grep("Pattern Searching") subgraph Lab Skills linux/help -.-> lab-558804{{"How to check if specific hardware is detected in Linux"}} linux/ls -.-> lab-558804{{"How to check if specific hardware is detected in Linux"}} linux/cat -.-> lab-558804{{"How to check if specific hardware is detected in Linux"}} linux/grep -.-> lab-558804{{"How to check if specific hardware is detected in Linux"}} end

Check CPU details with lscpu

In this step, you'll learn how to get detailed information about your computer's CPU (Central Processing Unit) using the lscpu command. The CPU is the "brain" of your computer, performing most of the calculations. Understanding its specifications can be helpful for troubleshooting or optimizing performance.

The lscpu command gathers CPU architecture information from /proc/cpuinfo and displays it in a human-readable format.

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

Now, type the following command and press Enter:

lscpu

You will see output similar to this:

Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         48 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  <number>
  On-line CPU(s) list:   0-<number-1>
Vendor ID:               GenuineIntel
  Model name:            <CPU Model Name>
    Flags:               <flags>
NUMA node(s):            1
  <More details...>

Let's break down some of the key information you might see:

  • Architecture: Shows the CPU architecture (e.g., x86_64).
  • CPU(s): The total number of CPUs or cores available.
  • Vendor ID: The manufacturer of the CPU (e.g., GenuineIntel, AuthenticAMD).
  • Model name: The specific model of your CPU.

The output provides a wealth of technical details about your CPU. Don't worry if you don't understand everything right away. The important part is knowing how to access this information when you need it.

You can also use lscpu with options to get specific information. For example, to see only the number of CPU cores, you could use:

lscpu -p=core,socket | grep -v '^#'

This command uses the -p option to specify the output format (core and socket) and pipes the output to grep -v '^#' to remove comment lines.

For now, just running lscpu is sufficient to get a general overview.

Click Continue to proceed to the next step.

List PCI devices with lspci

In this step, you'll learn how to list the PCI (Peripheral Component Interconnect) devices connected to your system using the lspci command. PCI is a standard bus that connects hardware devices like network cards, sound cards, and graphics cards to the computer's motherboard.

The lspci command is a utility for displaying information about PCI buses and devices in the system.

Make sure your terminal is open. Type the following command and press Enter:

lspci

You will see a list of devices, similar to this:

00:00.0 Host bridge: Intel Corporation <Device Name> (rev 06)
00:01.0 PCI bridge: Intel Corporation <Device Name> (rev 06)
00:01.1 PCI bridge: Intel Corporation <Device Name> (rev 06)
00:02.0 VGA compatible controller: Intel Corporation <Device Name> (rev 06)
00:03.0 Audio device: Intel Corporation <Device Name> (rev 06)
00:04.0 Signal processing controller: Intel Corporation <Device Name> (rev 06)
00:05.0 Non-Volatile memory controller: Intel Corporation <Device Name>
00:06.0 PCI bridge: Intel Corporation <Device Name> (rev 06)
00:07.0 PCI bridge: Intel Corporation <Device Name> (rev 06)
00:08.0 System peripheral: Intel Corporation <Device Name> (rev 06)
00:09.0 PCI bridge: Intel Corporation <Device Name> (rev 06)
00:0d.0 USB controller: Intel Corporation <Device Name> (rev 06)
00:10.0 PCI bridge: Intel Corporation <Device Name> (rev 06)
00:12.0 SATA controller: Intel Corporation <Device Name> (rev 06)
00:13.0 PCI bridge: Intel Corporation <Device Name> (rev 06)
00:14.0 SMBus: Intel Corporation <Device Name> (rev 06)
00:15.0 PCI bridge: Intel Corporation <Device Name> (rev 06)
00:16.0 Communication controller: Intel Corporation <Device Name> (rev 06)
00:17.0 PCI bridge: Intel Corporation <Device Name> (rev 06)
00:1f.0 ISA bridge: Intel Corporation <Device Name> (rev 06)
00:1f.3 Multimedia controller: Intel Corporation <Device Name> (rev 06)
00:1f.4 SMBus: Intel Corporation <Device Name> (rev 06)
00:1f.5 Serial bus controller [0c80]: Intel Corporation <Device Name> (rev 06)
00:1f.6 Ethernet controller: Intel Corporation <Device Name> (rev 06)

Each line represents a PCI device. The output shows the device's address on the PCI bus, its type, and the manufacturer and model name if available.

This command is useful for identifying the hardware components connected via the PCI bus, which can be helpful when installing drivers or troubleshooting hardware issues.

You can use the -v option for a more verbose output, providing more details about each device:

lspci -v

This will give you a much longer output with more technical specifications for each device.

For this step, simply running lspci is sufficient to see the list of devices.

Click Continue to move on.

Inspect hardware in /proc/devices

In this step, you'll explore the /proc filesystem, specifically the /proc/devices file, to get a list of character and block devices configured on your system. The /proc filesystem is a virtual filesystem that provides information about processes and other system information. It's a great place to find details about your running system.

Character devices are devices that transfer data character by character, like a terminal or a serial port. Block devices transfer data in fixed-size blocks, like hard drives or CD-ROM drives.

To view the contents of the /proc/devices file, you can use the cat command. Make sure your terminal is open. Type the following command and press Enter:

cat /proc/devices

You will see output similar to this:

Character devices:
  1 mem
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  6 lp
  7 vcs
 10 misc
 13 input
 14 sound
 21 sg
 29 fb
 81 video4linux
 89 rtc
116 alsa
128 ptm
136 pts
180 usb
189 usb_device
204 ttyLd
207 ttyprintk
240 hidraw
241 usb/hiddev
242 i2c
243 spi
244 gpio
245 pps
246 rfkill
247 bsg
248 watchdog
249 ptp
250 crng
251 pstore
252 vfio
253 aux
254 rtc
259 bdi

Block devices:
  7 loop
  8 sd
  9 md
 65 sd
 66 sd
 67 sd
 68 sd
 69 sd
 70 sd
 71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
259 blkext

The output is divided into two sections: "Character devices" and "Block devices". Each line lists a device type and its major device number. The major device number is used by the kernel to identify the driver responsible for managing the device.

This file provides a low-level view of the devices registered with the kernel. While you might not interact with this file frequently, it's a fundamental part of the Linux system and understanding its existence is valuable.

Click Continue to complete this lab.

Summary

In this lab, you learned how to check if specific hardware is detected in Linux. You started by using the lscpu command to obtain detailed information about your CPU, including its architecture, number of cores, vendor, and model name. This command gathers data from /proc/cpuinfo and presents it in a human-readable format, providing essential specifications for troubleshooting or performance analysis.

Next, you explored how to list PCI devices using the lspci command, which is crucial for identifying connected hardware like graphics cards, network adapters, and storage controllers. Finally, you learned how to inspect hardware information directly from the /proc/devices file, which lists character and block devices currently registered in the kernel, offering another way to verify hardware detection.