Skip to main content
Commands

lshw Command in Linux: Get Hardware Details

The lshw command lists the hardware details of your Linux system. You can categorize it to get details on different kinds of hardware.

Sagar Sharma

While running any operating system, a user will find himself in a situation where he wants to know all the hardware details.

And when you're running Linux, there's nothing better than using the lshw (list hardware) command for that purpose.

So in this tutorial, I'm going to share multiple examples of how you can use the lshw command to get hardware info.

How to use the lshw command

📋
The lshw command requires the sudo privileges to get some low-level and privileged information.

To use the lshw command, you'd have to follow the simple command syntax:

lshw [-format] [options]

Here,

  • [-format]: is where you specify the output format between HTML, XML, JSON, sort (shows the hardware paths), and bus info (shows bus information).
  • [options]: Used to tweak the default behavior of the lshw command.

In case you're curious about the effects when executed without any additional flags or formatting options, here you have it:

sudo lshw
use lshw command without any options

It will give you every hardware detail possible with the lshw command and that's not the best way to use the lshw.

So let's look at how you can use the lshw command to derive specific information only.

1. Show network information

To display the network information, you'd have to use the -C to specify the class and the network as shown:

sudo lshw -C network
show network hardware information using the lshw command in Linux

As you can see, I have two hardware devices for networking purposes: wifi and ethernet including its logical name and vendor.

2. Get the memory details

Using this method, you will get details of individual RAM slots and the cache, including information like RAM size, clock speed, etc.

And to do so, you'll be using the same -C flag but with the memory option:

sudo lshw -C memory
list the memory hardware details using the lshw command in Linux

What the above image suggests is I have 4 RAM slots, each equipped with 8GB of RAM and clocked at 2667MHz.

3. Get the storage information

By far this is the most useful way you can use the lshw command in my opinion as it lists all the connected storage devices with all the necessary information.

And to do so, you can use the lshw command in the following manner:

sudo lshw -class storage
get storage information using the lshw command

4. Get the system information

The system information includes details like system architecture, motherboard name and manufacturer, and number of plug-and-play ports.

To get the system information, you use the system flag as shown:

sudo lshw -C system
get the system information using the lshw command in Linux

As you can see, I have a Gigabyte motherboard with 7 plug-and-play slots!

5. Get the sound card info

There are times when one wants to verify the manufacturer of the sound card and in that case, you can use the following command:

sudo lshw -C multimedia
get sound card info in Linux using the lshw command

6. Get the display controller information

If you want to know which GPU is being used to get the display output, then, you can use the lshw command with the display flag:

sudo lshw -C display
get the graphics card info using the lshw command in Linux

As I'm using the integrated graphics, it is showing the Intel product.

7. Display the PCIE bridge information

If you're looking for a way to get the PCIe bridge information, then, you'd have to use the bridge flag as shown:

sudo lshw -C bridge
get details of PCIe bridge in Linux

8. Display bus information

If you don't know, buses in computers are nothing but a communication system that is used to transfer data inside the system itself.

And if you want to list down the buses in your system, then, you can use the bus flag with the lshw command as shown:

sudo lshw -C bus
get the bus information of Linux using the lshw command

As you can see, it listed all the buses including the USB.

9. Display CPU information

To get the details on the processor of your system, you can use the lshw command in this manner:

sudo lshw -C CPU

This will give you details on CPU type, manufacturer, clock speed, number of cores, threads and many more related things.

CPU details with lshw command

This is what you've learned so far

Here's the summary of the lshw command with the options used in this tutorial:

option Description
network Gets the details of the network hardware devices.
memory Displays the details of RAM in your system.
storage Prints details of the storage drives.
system Gets the details of the motherboard and plug-and-play slots.
multimedia Details of the sound card of your system.
display Know more about what is powering the display output.
bridge Displays info about the PCIe bridges.
bus It will list down buses and their details.
CPU List the processor details

Wrapping Up...

This was a tutorial on how to use the lshw command and learn more about the hardware installed on your system.

I hope you find this guide helpful and if you have any queries, feel free to ask in the comments.

Sagar Sharma