Welcome to lshw, the great tool often overlooked even by seasoned Linux professionals.

What Islshw?

One can rememberlshwby thinking about

(the command which lets you list directory contents) and

for hardware.

The main page of the Homepage homelab dashboard with services running on it.

Perhaps other tools have taken too much of a front posting on search engines and similar.

you could even install a graphical version of the same tool using a separate package, namelylshw-gtk.

Double click this, then double click, for exampleMotherboardin the second column, and so on.

Article image

Do you know the difference between a crash and error and an assert?

OurAsserts, Errors, and Crashesarticle explains the difference.

Let’s make this work a bit better by limiting the output to what we are interested in.

lshw-gtk main dialog window after scanning

Firstly we should explore the hardware classes of output available to us.

Still, the output list can be 1-2 pages long, depending on your terminal configs.

We should also at this point remember to always uselshwwithsudo.

lshw output in short format (using the -short option) also showing device classes, fist 6 lines of output

This will ensure that the output will not be incomplete or inaccurate.

Runninglshwassudoshould be safe (famous last words!)

We also see that 8GiB of memory was assigned to this VM (Virtual Machine).

Using lshw to establish and test whether we are running inside VirtualBox

‘; else echo ‘This is not a VirtualBox VM!

‘; fi

Here we executed multiple commands, each time building the command into more complexity.

If the output does not contain ‘VirtualBox’, the command will not yield any output.

Basically, we are asking theBashinterpreter to test whether the output of the second command matches ‘VirtualBox’.

If so, we can quite confidently sayWe are using VirtualBox!.