How to use the command 'hwinfo' (with examples)
- Linux
- December 25, 2023
The ‘hwinfo’ command is used to probe and retrieve information about the hardware present in the system. It provides detailed information about various hardware components such as graphics cards, network devices, disks, and CD-ROM drives. This article will illustrate five different use cases of the ‘hwinfo’ command, along with their code and example outputs.
Use case 1: Get graphics card information
Code:
hwinfo --gfxcard
Motivation: This use case is helpful when you need to identify the graphics card present in your system or gather information about it for troubleshooting purposes.
Explanation: The ‘–gfxcard’ option is used with the ‘hwinfo’ command to specifically probe and display graphics card information.
Example output:
22: PCI 100.0: 0300 VGA compatible controller (VGA)
[Created at pci.386]
Unique ID: _Znp.ddfXg0WUpH3
SysFS ID: /devices/pci0000:00/0000:00:01.0/0000:01:00.0
SysFS BusID: 0000:01:00.0
Hardware Class: graphics card
Model: "NVIDIA GP107 [GeForce GTX 1050 Ti]"
Vendor: pci 0x10de "NVIDIA Corporation"
Device: pci 0x1c82 "GP107 [GeForce GTX 1050 Ti]"
SubVendor: pci 0x3842 "Gigabyte Technology Co., Ltd"
SubDevice: pci 0x3663
Revision: 0xa1
Driver: "nvidia"
Driver Modules: "nvidia"
Memory Range: 0xfc000000-0xfcffffff (rw,non-prefetchable)
Memory Range: 0xc0000000-0xcfffffff (ro,non-prefetchable)
Memory Range: 0xd0000000-0xd1ffffff (ro,non-prefetchable)
I/O Ports: 0xe000-0xe07f (rw)
IRQ: 255 (no events)
Module Alias: "pci:v000010DEd00001C82sv00003842sd00003663bc03sc00i00"
Driver Info #0:
Driver Status: nouveau is not active
Driver Activation Cmd: "modprobe nouveau"
Driver Info #1:
Driver Status: nvidia_drm is active
Driver Activation Cmd: "modprobe nvidia_drm"
Driver Info #2:
Driver Status: nvidia is active
Driver Activation Cmd: "modprobe nvidia"
Use case 2: Get network device information
Code:
hwinfo --network
Motivation: This use case comes in handy when you want to list and analyze the network devices present in your system.
Explanation: The ‘–network’ option is used with the ‘hwinfo’ command to probe and display information regarding network devices.
Example output:
02: None 00.0: 10701 Ethernet
[Created at net.124]
Unique ID: l2D4.asmtEgdFXbZ
Parent ID: _Znp.ddfXg0WUpH3
SysFS ID: /class/net/eno1
SysFS Device Link: /devices/pci0000:00/0000:00:1f.6/net/eno1
Hardware Class: network interface
Model: "Intel Ethernet Connection I219-V"
Driver: "e1000e"
Driver Modules: "e1000e"
Device File: eno1
HW Address: xx:xx:xx:xx:xx:xx
Permanent HW Address: xx:xx:xx:xx:xx:xx
Link detected: yes
Module Alias: "pci:v00008086d000015BCsv00001028sd00002238bc02sc00i00"
Driver Info #0:
Driver Status: e1000e is active
Driver Activation Cmd: "modprobe e1000e"
Config Status: cfg=new, avail=yes, need=no, active=unknown
Use case 3: List disks and CD-ROM drives, abbreviating the output
Code:
hwinfo --short --disk --cdrom
Motivation: This use case is useful when you want to quickly list the disks and CD-ROM drives present in your system, without the need for extensive details.
Explanation: The ‘–short’ option is used with the ‘hwinfo’ command to provide an abbreviated output. The ‘–disk’ and ‘–cdrom’ options are used to specifically list disks and CD-ROM drives, respectively.
Example output:
16: IDE 02.0: 10600 Disk
[Created at block.245]
Unique ID: xxxx.xxxx.xxxx.xxxx
Parent ID: x.xxx.xxxx.xxxx
SysFS ID: /class/block/sda
SysFS Device Link: /devices/pci0000:00/0000:00:1f.2/ata2/host1/target1:0:0/1:0:0:0/block/sda
Hardware Class: disk
Model: "SAMSUNG HD204UI"
Vendor: "SAMSUNG"
Device: "HD204UI"
Revision: "1AQ1"
Driver: "ahci", "sd"
Driver Modules: "ahci"
Device File: /dev/sda
Device Pointer: /dev/disk/by-id/xxxx.xxxx.xxxx.xxxx
Device Node: /dev/sda
Device Link: /dev/disk/by-id/xxxx.xxxx.xxxx.xxxx
Size: 1953525168 sectors a 512 bytes
Config Status: cfg=new, avail=yes, need=no, active=unknown
Attached to: #11 (IDE interface)
66: SCSI 11.0: 10602 CD-ROM (DVD-RAM)
[Created at block.245]
Unique ID: UmtD.cQzO1BsHl6D
Parent ID: ShHx.xTc3YEv0.I5
SysFS ID: /class/block/sr0
SysFS Device Link: /devices/pci0000:00/0000:00:1f.2/ata3/host2/target2:0:0/2:0:0:0/block/sr0
Hardware Class: cdrom
Model: "HL-DT-ST DVD-RAM GH24NSC0"
Vendor: "HL-DT-ST"
Device: "DVD-RAM GH24NSC0"
Revision: "LG00"
Driver: "ata_piix", "sr"
Device File: /dev/sr0 (/dev/sg0)
Device Files: /dev/sr0, /dev/block/11:0, /dev/sg0
Device Number: block 11:0 (char 21:0)
Drive status: no medium
Config Status: cfg=new, avail=yes, need=no, active=unknown
Attached to: #4 (IDE interface)
Use case 4: Write all hardware information to a file
Code:
hwinfo --all --log path/to/file
Motivation: This use case is useful when you want to collect comprehensive hardware information and save it to a file for future reference or analysis.
Explanation: The ‘–all’ option is used to retrieve information about all available hardware components. The ‘–log’ option is used to specify the path and filename where the information should be stored.
Example output: The hardware information is written to the specified file in a detailed format.
Use case 5: Display help
Code:
hwinfo --help
Motivation: This use case is helpful when you need a quick reference on how to use the ‘hwinfo’ command or to understand the available options.
Explanation: The ‘–help’ option is used to display the help message, which provides information about the usage, options, and other details related to the ‘hwinfo’ command.
Example output: The help message is displayed, providing detailed information about various options, their usage, and their effects.
Conclusion:
The ‘hwinfo’ command is a powerful tool to quickly probe and retrieve extensive information about the hardware present in a system. By using the different options, you can obtain specific details about graphics cards, network devices, disks, and CD-ROM drives. Additionally, you can save the complete hardware information to a file for offline analysis. The ‘hwinfo’ command comes with a useful ‘–help’ option, providing assistance on how to utilize its features effectively.