How to Display Linux Hardware Info via Command Line

get hardware info from linux

When a user works on a Linux system, in some cases, the user needs to know the information about the hardware under the operating system. This helps us to install compatible applications and utilities which adapt to hardware components of the system.

This tutorial will go through many utilities with detailed explanations of how to get the Linux hardware information.

1. lshw

The lshw stands for List Hardware. It collects the detailed information of the hardware on your system. lshw can show you the name of mainboard, CPU information, bus speed and firmware version and more.
In order to display the information of all the hardware components, run:

$ sudo lshw

If you want to shorten the result, run the command with -short option:

$ sudo lshw -short

You will receive the brief list of hardware components on your Linux system:

H/W path             Device     Class          Description
                                system         Precision T1700 (Precision T1700)
/0                              bus            0TDG4V
/0/0                            memory         64KiB BIOS
/0/3a                           processor      Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
/0/3a/3b                        memory         256KiB L1 cache
/0/3a/3c                        memory         1MiB L2 cache
/0/3a/3d                        memory         8MiB L3 cache
/0/3e                           memory         8GiB System Memory
/0/3e/0                         memory         DIMM [empty]

Display disk properties and storage device properties on Linux system by running:

$ sudo lshw -class disk -class storage

You can get the brief result you may use the option -short:

$ sudo lshw -class disk -class storage -short

This tool is also available in a GTK graphical version:

2. Inxi

Inxi is a powerful feature-rich command line tool for Linux users when they want to get the information of system hardware, CPU, RAM, Graphics card, drivers, battery, kernel, process information, and more.

By default, Inxi is not pre-installed on Linux. In order to use it, install the inxi package by running the following command:

$ sudo apt install inxi

Running inxi without any option:

$ inxi

The command will return the information of CPU and Memory as follows:

CPU: Quad Core Intel Core i7-4790 (-MT MCP-) speed/min/max: 2195/800/4000 MHz Kernel: 5.4.0-37-generic x86_64 Up: 1d 2h 10m 
Mem: 5649.7/7869.6 MiB (71.8%) Storage: 465.76 GiB (5.9% used) Procs: 412 Shell: bash 5.0.16 inxi: 3.0.38

In order to get the graphics info, run the following command:

$ inxi -G
          Graphics:  Device-1: Intel Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics driver: i915 v: kernel 
           Device-2: NVIDIA GM107GL [Quadro K620] driver: nvidia v: 440.64 
           Display: x11 server: X.Org 1.20.8 driver: modesetting,nvidia unloaded: fbdev,nouveau,vesa 
           resolution: 1920x1080~60Hz, 1920x1080~60Hz 
           OpenGL: renderer: Quadro K620/PCIe/SSE2 v: 4.6.0 NVIDIA 440.64 

To show audio/sound card information, run:

$ inxi -A
Audio:     Device-1: Intel Xeon E3-1200 v3/4th Gen Core Processor HD Audio driver: snd_hda_intel 
           Device-2: Intel 8 Series/C220 Series High Definition Audio driver: snd_hda_intel 
           Device-3: NVIDIA GM107 High Definition Audio [GeForce 940MX] driver: snd_hda_intel 
           Sound Server: ALSA v: k5.4.0-39-generic 

To show battery data, charge, condition, plus extra information (if battery present), run the command with -B option:

$ inxi -B
Battery:   ID-1: BAT0 charge: 40.0 Wh condition: 40.0/48.8 Wh (82%)

3. hwinfo

The hwinfo command is a powerful tool for Linux users to get the detail of hardware components of system. It helps you collect almost of information about: CPU, USB controller, graphics controller, network devices and more.

You can use hwinfo command with --short and --devicetype options to list a specific type of information.
Display information about NIC cards and find out what eth0, eth1 stands for by running:

$ sudo hwinfo --netcard --short

In order to display storage information with hwinfo command, run:

$ sudo hwinfo --storage --short

Likewise, to display list of partitions and hard disks, run the following command:

$ sudo hwinfo --block --short

4. lscpu

The lscpu will show you all the information of your CPU such as number of CPUs, cores, threads, sockets and CPU family, caches, model and more.

You can get the detail of the CPU by running the following command:

$ lscpu

The output of the command will be something likes this:

Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   39 bits physical, 48 bits virtual
CPU(s):                          8
On-line CPU(s) list:             0-7
Thread(s) per core:              2
Core(s) per socket:              4
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       GenuineIntel
CPU family:                      6
Model:                           60
Model name:                      Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
Stepping:                        3
CPU MHz:                         888.262
CPU max MHz:                     4000,0000
CPU min MHz:                     800,0000
BogoMIPS:                        7183.65
Virtualization:                  VT-x
L1d cache:                       128 KiB
L1i cache:                       128 KiB
L2 cache:                        1 MiB
L3 cache:                        8 MiB
NUMA node0 CPU(s):               0-7
Vulnerability Itlb multihit:     KVM: Mitigation: Split huge pages
Vulnerability L1tf:              Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable

Moreover, if you want to view the speed of the CPU in MHz, run the command:

$ lscpu | grep -i MHz

5. lsscsi

The lsscsi is used to list all of the SCSI (Small Computer System Interface) devices and NVMe (Non-Volatile Memory express) devices on your machine.

By default, the lsscsi is not pre-installed on Ubuntu, run the following command to install:

$ sudo apt install lsscsi

You can simply use the command by running:

$ lsscsi

The output:

[0:0:0:0]    disk    ATA      ST500DM002-1SB10 CC43  /dev/sda

6. lsblk

The lsblk command will show you the details of all the block devices in a tree format. It gathers information from sysfs filesystem and udev database.

In order to list all of block devices and their partitions and sizes, let's run the following command:

$ lsblk


sda               8:0    0   40G  0 disk 
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   39G  0 part 
  ├─centos-root 253:0    0 35,1G  0 lvm  /
  └─centos-swap 253:1    0  3,9G  0 lvm  [SWAP]
sr0              11:0    1  918M  0 rom  

7. lsusb

The lsusb is a powerful tool for displaying all the information about USB devices connected to USB buses of your Linux system. The information contains: speed, class, vendor id, product id, bus of USB devices etc.

You can run the following command to get brief information:

$ lsusb
Bus 002 Device 003: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
Bus 002 Device 002: ID 8087:8000 Intel Corp. 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 003: ID 046d:c31d Logitech, Inc. Media Keyboard K200
Bus 001 Device 002: ID 8087:8008 Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

If you want to display the specified device with Bus and Device number, run the command with '-s' option. For example:

$ lsusb -s 1:1

The output:

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

8. lspci

This standard Linux utility shows what your systems have got internally. The command is a combination of ls, the standard command to list files and PCI that is for the peripheral connection. You can also expect your results to include AGP and onboard components like your USB chipset.

The command is much helpful in diagnosing bugs related to PCI devices. Using '-t' option of lspci command you can see PCI layout in a tree format.

$ lspci -t

In order to get more detailed information, use -v option with -t option:

$ lspci -tv

You can just run lspci command to display basic device information:

$ lspci

9. Using dmesg

The dmesg command is useful to find out some info about hardware events. It displays the contents of the system log.

The following command lists all references to universal serial bus devices:

$ sudo dmesg | grep -i usb
[    0.754057] ACPI: bus type USB registered
[    0.754057] usbcore: registered new interface driver usbfs
[    0.754057] usbcore: registered new interface driver hub
[    0.754057] usbcore: registered new device driver usb
[    1.708662] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.709302] ehci-pci 0000:02:01.0: new USB bus registered, assigned bus number 1
[    1.724205] ehci-pci 0000:02:01.0: USB 2.0 started, EHCI 1.00
[    1.724285] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.03
[    1.724286] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.724288] usb usb1: Product: EHCI Host Controller
[    1.724289] usb usb1: Manufacturer: Linux 5.3.0-53-generic ehci_hcd
[    1.724290] usb usb1: SerialNumber: 0000:02:01.0
[    1.724478] hub 1-0:1.0: USB hub found
[    1.724731] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    1.724756] uhci_hcd: USB Universal Host Controller Interface driver
[    1.725463] uhci_hcd 0000:02:00.0: new USB bus registered, assigned bus number 2
[    1.725845] usb usb2: New USB device found, idVendor=1d6b, idProduct=0001, bcdDevice= 5.03
[    1.725846] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.725847] usb usb2: Product: UHCI Host Controller
[    1.725848] usb usb2: Manufacturer: Linux 5.3.0-53-generic uhci_hcd

The following command shows all serial ports:
$ sudo dmesg | grep -i tty

In order to display the details about physical memory that is RAM, run:

$ sudo dmesg | grep -i memory

10. Using dmidecode command

Dmidecode stands for Desktop Management Interface decode, it is a powerful tool for retrieving the information of CPU, RAM, serial numbers, BIOS,... The command will show you the hardware details in a human-readable format.

In order to get the Information about BIOS, run:

$ sudo dmidecode -t bios
# dmidecode 3.1
Getting SMBIOS data from sysfs.
SMBIOS 2.7 present.

Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
	Vendor: Phoenix Technologies LTD
	Version: 6.00
	Release Date: 12/12/2018
	Address: 0xEA490
	Runtime Size: 88944 bytes
	ROM Size: 64 kB
		ISA is supported
		PCI is supported
		PC Card (PCMCIA) is supported
		PNP is supported
		APM is supported
		BIOS is upgradeable
		BIOS shadowing is allowed
		ESCD support is available
		Boot from CD is supported
		Selectable boot is supported
		EDD is supported
		Print screen service is supported (int 5h)
		8042 keyboard services are supported (int 9h)
	BIOS Revision: 4.6
	Firmware Revision: 0.0

If you want to display the hardware components information by ID, run the command with -t option following by a number ID (DMI).

For example, the following command will show you the information of memory Device:

$ sudo dmidecode -t 17

11. hdparm

The hdparm stands for Hard Disk Parameter. It's a Linux command line utility used for handling hard disk devices. You can also use hdparm command to set parameters such as power management, sleep mode, drive caches, Direct Memory Access settings, etc.

For instance, in order to display information of the hard disk, run the following command:

$ sudo hdparm -I /dev/sda

Another example, you can use hdparm to test the speed of hard disk by running the following command:

$ sudo hdparm -t /dev/sda

12. From /proc file

The /proc directory contains lots of system and hardware information. You can try the following commands to get more info on devices:

$ procinfo

The output of the command will be something likes this:

Memory:        Total        Used        Free     Buffers                       
RAM:         2006008      916292     1089716       32776                       
Swap:         969960      234240      735720                                   

Bootup: Thu Jun 11 15:57:16 2020   Load average: 0.21 0.08 0.02 1/416 21023    

user  :           01:34:39.97   0.2%  page in :         10461037               
nice  :           00:04:15.50   0.0%  page out:         26333420               
system:           01:10:25.63   0.2%  page act:          2931885               
IOwait:           00:13:23.38   0.0%  page dea:          2769585               
hw irq:           00:00:00.00   0.0%  page flt:         93862705               
sw irq:           00:09:00.39   0.0%  swap in :             6039               
idle  :     4w 3d 05:52:38.52  99.6%  swap out:            63794               
uptime:     2w 1d 17:21:09.14         context :        444207086  

irq   0:          3  2-edge timer        irq  38:          0  372736-edge PCIe 
irq   1:          9  1-edge i8042        irq  39:          0  374784-edge PCIe 
irq   8:          1  8-edge rtc0         irq  40:          0  376832-edge PCIe 

docker0     TX 566.00B       RX 0.00B         lo          TX 255.69KiB     RX 255.69KiB    
ens160      TX 48.13MiB      RX 667.44MiB      

In addition, you can run some other commands in order to get information about CPU, Memory, and PCI devices respectively.

$ cat /proc/cpuinfo
$ cat /proc/meminfo
$ cat /proc/pci

13. free

Sometimes, you want to know whether the free memory (RAM) is enough to launch or install a new program? In this case, you can use free command to get information about memory detail in your Linux system.

The free command not only shows you information about the total amount of physical RAM and swap but also free and used memory. For example:

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           1,9G        1,0G        760M         14M        165M        762M
Swap:          947M        243M        704M


In this tutorial, we learned how to use Linux command line to get information about the hardware components of the system.

Thanks for reading and please leave your suggestion in the below comment section.

Read Also:

Leave a Comment