HardwareLinuxOpen Source SoftwareTutorials

How to find and show hardware information in Linux

Microsoft's Windows has one very nice feature concerning hardware detection: The Windows device manager. The different components are (mostly) nicely listed in an overview.

The "Device Manager" in Windows is (mostly) pretty helpful to show hardware components

Such information is not only helpful, it may be necessary when a hardware component failed or is about to fail and needs to be replaced.

But how does one do that in Linux? In this article we describe several ways how to list and show the hardware information of installed components on the command line (cli).

How to find CPU information on the command line

For this situation, the command lscpu is made to help you. It does not only show the name of the installed CPU, but also how many cores and what kind of features (such as virtualization) are enabled.

The following output of lscpu shows the relevant information of an Intel i5-2300 CPU:

ck@linux1 ~ $ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    1
Core(s) per socket:    4
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 42
Model name:            Intel(R) Core(TM) i5-2300 CPU @ 2.80GHz
Stepping:              7
CPU MHz:               2633.168
CPU max MHz:           3100.0000
CPU min MHz:           1600.0000
BogoMIPS:              5618.85
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              6144K
NUMA node0 CPU(s):     0-3
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer aes xsave avx lahf_lm epb pti tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm ida arat pln pts

The same command obviously also works for other CPUs, here on an AMD Ryzen 7 1700:

ck@linux2:~$ lscpu
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
Address sizes:       43 bits physical, 48 bits virtual
CPU(s):              16
On-line CPU(s) list: 0-15
Thread(s) per core:  2
Core(s) per socket:  8
Socket(s):           1
NUMA node(s):        1
Vendor ID:           AuthenticAMD
CPU family:          23
Model:               1
Model name:          AMD Ryzen 7 1700 Eight-Core Processor
Stepping:            1
CPU MHz:             1348.227
CPU max MHz:         3000.0000
CPU min MHz:         1550.0000
BogoMIPS:            5987.92
Virtualization:      AMD-V
L1d cache:           32K
L1i cache:           64K
L2 cache:            512K
L3 cache:            8192K
NUMA node0 CPU(s):   0-15
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb hw_pstate sme ssbd sev ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 xsaves clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif overflow_recov succor smca

How to find motherboard information on the command line

The motherboard usually "just runs" but you should not forget about new firmware versions. They often boost the performance and add support for different or newer CPU models. To find out what motherboard is used, use the dmidecode command.

This command not only shows information about the motherboard itself, but also about other motherboard-related hardware, such as installed memory (RAM) dimms or USB slots. To only show the motherboard vendor and product/model, use dmidecode with the -s string. To run dmidecode, you require sudo privileges.

# Machine 1
ck@linux1 ~ $ sudo dmidecode -s baseboard-manufacturer
ASUSTeK Computer INC.
ck@linux1 ~ $ sudo dmidecode -s baseboard-product-name
P8H67-M EVO

# Machine 2
ck@linux2 ~ $ sudo dmidecode -s baseboard-manufacturer
ASRock
ck@linux2 ~ $ sudo dmidecode -s baseboard-product-name
AB350 Gaming-ITX/ac

To show all relevant motherboard information, use dmidecode with the -t type parameter:

ck@linux1 ~ $ sudo dmidecode -t baseboard
# dmidecode 3.0
Getting SMBIOS data from sysfs.
SMBIOS 2.6 present.

Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
	Manufacturer: ASUSTeK Computer INC.
	Product Name: P8H67-M EVO
	Version: Rev 1.xx
	Serial Number: XXXXXXXXXXXXXXX
	Asset Tag: To be filled by O.E.M.
	Features:
		Board is a hosting board
		Board is replaceable
	Location In Chassis: To be filled by O.E.M.
	Chassis Handle: 0x0003
	Type: Motherboard
	Contained Object Handles: 0

Handle 0x0023, DMI type 10, 6 bytes
On Board Device Information
	Type: Ethernet
	Status: Enabled
	Description: Onboard Ethernet

Invalid entry length (16). Fixed up to 11.
Handle 0x0052, DMI type 41, 11 bytes
Onboard Device
	Reference Designation:  Onboard IGD
	Type: Video
	Status: Enabled
	Type Instance: 1
	Bus Address: 0000:00:02.0

Handle 0x0053, DMI type 41, 11 bytes
Onboard Device
	Reference Designation:  Onboard LAN
	Type: Ethernet
	Status: Enabled
	Type Instance: 1
	Bus Address: 0000:00:19.0

Handle 0x0054, DMI type 41, 11 bytes
Onboard Device
	Reference Designation:  Onboard 1394
	Type: Other
	Status: Enabled
	Type Instance: 1
	Bus Address: 0000:03:1c.2

How to find graphics card / GPU information on the command line

When you need to find out which graphics card or GPU (Graphics Processing Unit) is installed in a system, you may have to use different kinds of commands. Depending on the GPU vendor, some commands might not work and/or the implementation of tools is different.

Using glxinfo

Let's start with glxinfo, which is available from the mesa-utils package. From the man page:

The glxinfo program shows information about the OpenGL and GLX implementations running on a given X display.
The information includes details about the server- and client-side GLX implementation, the OpenGL and GLU implementations as well as a list of available GLX visuals.

man glxinfo(1)

By specifically grepping for the Device name, this should show the installed GPU:

ck@linux1 ~ $ glxinfo | grep Device
    Device: Radeon RX 580 Series (POLARIS10 / DRM 3.23.0 / 4.15.0-133-generic, LLVM 6.0.0) (0x67df)

However glxinfo only works correctly on a computer or server with X (display) enabled and when you are logged in physically. If you attempt to do this from remote (using SSH for example), you probably get an error like this:

ck@linux1 ~ $ glxinfo | grep Device
Error: unable to open display

Using lspci

Another command to find the installed GPU is lspci, which should show the name and model as "VGA compatible controller":

# Machine 1
ck@linux1 ~ $ lspci | grep VGA
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X] (rev e7)

# Machine 2
ck@linux2:~$ lspci | grep VGA
26:00.0 VGA compatible controller: NVIDIA Corporation GK208 [GeForce GT 730] (rev a1)

On machine 1, only the GPU model's family is shown, unfortunately not the exact model name (RX 580), but on machine 2, the correct GPU (GeForce GT 730) is shown.

Nvidia cards

Linux and Nvidia have an interesting history and chief Linux maintainer Linus Torvalds even publicly said once "F%ck you, Nvidia". He was referring to problems with driver and program implementation for Nvidia cards in the Linux Kernel.

Torvalds giving Nvidia the middle finger in 2012

In general, as of this day, GPUs from AMD (formerly known as ATI), have better detection and work better, by default, with the Linux Kernel. Nvidia's GPUs kind of work with the basic open source drivers (nouveau), but to be able to use the full performance, Nvidia's own driver and Kernel module should be installed.

Once installed, the Kernel module nvidia_drm should be showing up in lsmod:

ck@linux2:~$ lsmod | grep nvidia
nvidia_drm             49152  0
drm_kms_helper        208896  1 nvidia_drm
drm                   495616  3 drm_kms_helper,nvidia_drm
nvidia_modeset       1097728  1 nvidia_drm
nvidia              18653184  1 nvidia_modeset
ipmi_msghandler        65536  2 ipmi_devintf,nvidia

Nvidia has its own commands to work with GPUs. The nvidia-smi command not only shows the name of the installed card, it also shows the current usage (which is actually very useful and something like that would be great for all GPU vendors):

ck@linux2:~$ nvidia-smi 
Mon Mar  8 07:37:10 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.181.07   Driver Version: 418.181.07   CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GT 730      Off  | 00000000:26:00.0 N/A |                  N/A |
| 30%   38C    P0    N/A /  N/A |      0MiB /  4043MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0                    Not Supported                                       |
+-----------------------------------------------------------------------------+

How to find drive information on the command line

When it comes to hard (HDD) or solid state (SSD) drives, there is one great command which should always be installed: smartctl from the smartmontools package.

This long-existing (since 2002!) and still maintained command is able to identify your drive(s) and help determine the current health of these drives. The check_smart monitoring plugin also uses smartctl in the background. By using the -i parameter, the drive's "headers", including the drive vendor and model, are shown. smartcl requires root/sudo privileges.

# Machine 1
ck@linux1 ~ $ sudo smartctl -i /dev/sda
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.15.0-133-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Samsung based SSDs
Device Model:     Samsung SSD 850 EVO 500GB
Serial Number:    XXXXXXXXXXXXXXX
LU WWN Device Id: 5 002538 d400d9e4f
Firmware Version: EMT01B6Q
User Capacity:    500'107'862'016 bytes [500 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-2, ATA8-ACS T13/1699-D revision 4c
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Mon Mar  8 07:53:06 2021 CET
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

# Machine 2
root@linux2 ~ # smartctl -i /dev/sda
smartctl 6.6 2017-11-05 r4594 [x86_64-linux-4.19.0-14-amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Crucial/Micron Client SSDs
Device Model:     CT1000MX500SSD1
Serial Number:    XXXXXXXXXXXX
LU WWN Device Id: 5 00a075 1e10ce73f
Firmware Version: M3CR010
User Capacity:    1,000,204,886,016 bytes [1.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    Solid State Device
Form Factor:      2.5 inches
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-3 T13/2161-D revision 5
SATA Version is:  SATA 3.3, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Mon Mar  8 07:54:07 2021 CET
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

NVMe drives/cards can also be detected by smartctl, however not all NVMe cards show full SMART support. In this case use the nvme command from the nvme-cli package.

root@linux3:~# nvme list
Node         SN           Model                   Namespace Usage                 Format         FW Rev  
------------ ------------ ----------------------- --------- --------------------- -------------- -------
/dev/nvme0n1 XXXXXXXXXXXX Samsung SSD 960 PRO 1TB 1         0.00   B /  21.47  GB 512   B +  0 B 1.0

How to find memory / RAM information on the command line

To replace a memory DIMM it is not really required to use the exact same memory vendor and model again. Important here is the type, size and the clockspeed of a DIMM.

A generic way to obtain memory information, is to use dmidecode (again). This command should be able to show the motherboard's memory capacity (such as number of DIMMs and maximum installable memory) but also information per memory DIMM.

# Machine 1
ck@linux1 ~ $ sudo dmidecode | grep -A 7 "Physical Memory Array"
Physical Memory Array
	Location: System Board Or Motherboard
	Use: System Memory
	Error Correction Type: None
	Maximum Capacity: 32 GB
	Error Information Handle: 0x0059
	Number Of Devices: 4

# Machine 2
root@linux2 ~ # dmidecode | grep -A 7 "Physical Memory Array"
Physical Memory Array
	Location: System Board Or Motherboard
	Use: System Memory
	Error Correction Type: None
	Maximum Capacity: 256 GB
	Error Information Handle: 0x0009
	Number Of Devices: 2

The two outputs from above show the system board's (motherboard) memory capacities.

To show all memory information (motherboard's capacity and each installed memory DIMM), use the following dmidecode command:

root@linux2 ~ # sudo dmidecode --type memory
# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.0.0 present.

Handle 0x000A, DMI type 16, 23 bytes
Physical Memory Array
	Location: System Board Or Motherboard
	Use: System Memory
	Error Correction Type: None
	Maximum Capacity: 256 GB
	Error Information Handle: 0x0009
	Number Of Devices: 2

Handle 0x0011, DMI type 17, 40 bytes
Memory Device
	Array Handle: 0x000A
	Error Information Handle: 0x0010
	Total Width: 64 bits
	Data Width: 64 bits
	Size: 8192 MB
	Form Factor: DIMM
	Set: None
	Locator: DIMM 0
	Bank Locator: P0 CHANNEL A
	Type: DDR4
	Type Detail: Synchronous Unbuffered (Unregistered)
	Speed: 2134 MT/s
	Manufacturer: Unknown
	Serial Number: 00000000
	Asset Tag: Not Specified
	Part Number: CMK8GX4M1A2666C16   
	Rank: 1
	Configured Memory Speed: 1067 MT/s
	Minimum Voltage: 1.2 V
	Maximum Voltage: 1.2 V
	Configured Voltage: 1.2 V

Handle 0x0014, DMI type 17, 40 bytes
Memory Device
	Array Handle: 0x000A
	Error Information Handle: 0x0013
	Total Width: 64 bits
	Data Width: 64 bits
	Size: 8192 MB
	Form Factor: DIMM
	Set: None
	Locator: DIMM 0
	Bank Locator: P0 CHANNEL B
	Type: DDR4
	Type Detail: Synchronous Unbuffered (Unregistered)
	Speed: 2134 MT/s
	Manufacturer: Unknown
	Serial Number: 00000000
	Asset Tag: Not Specified
	Part Number: CMK8GX4M1A2666C16   
	Rank: 1
	Configured Memory Speed: 1067 MT/s
	Minimum Voltage: 1.2 V
	Maximum Voltage: 1.2 V
	Configured Voltage: 1.2 V

For each installed DIMM, the relevant information is showing. Thanks to this output, we know that are the installed DIMMs have a size of 8GB and a clock speed of 2134 MT/s (MHz). We can also see that they have the same model (Part Number CMK8GX4M1A2666C16), which turns out to be a Corsair Vengeance memory DIMM.

Quick overview: Which command for which hardware component

The following table is here to quickly show an overview which command to use for which hardware component.

HardwareCommandNotes
CPUlscpu
Motherboard
Mainboard
System board
dmidecode
AMD GPUglxinfoInstall mesa-utils package
Nvidia GPUnvidia-smiRequires Nvidia driver installed
Command comes bundled with driver
GPU (in general)lspci | grep VGAMight not show exact model
Hard drive
Solid state drive
NVMe drive
smartctlInstall smartmontools package
Might not work on NVMe drive
NVMe drivenvme listInstall from nvme-cli package
Memory
RAM Dimms
dmidecode

Claudio Kuenzler
Claudio has been writing way over 1000 articles on his own blog since 2008 already. He is fascinated by technology, especially Open Source Software. As a Senior Systems Engineer he has seen and solved a lot of problems - and writes about them.

You may also like

Comments are closed.

More in:Hardware