{"id":2946,"date":"2018-02-28T16:14:02","date_gmt":"2018-02-28T13:14:02","guid":{"rendered":"https:\/\/www.howtoforge.com\/linux-lshw-command\/"},"modified":"2018-02-28T16:14:02","modified_gmt":"2018-02-28T13:14:02","slug":"linux-lshw-command-tutorial-for-beginners-6-examples","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/linux-lshw-command-tutorial-for-beginners-6-examples\/","title":{"rendered":"Linux lshw Command Tutorial for Beginners (6 Examples)"},"content":{"rendered":"<p>The beauty of the Linux command line lies in the fact that you can do almost anything using the command line tools. Even if it involves fetching information on the system&#8217;s hardware components. If that&#8217;s what you intend to do, and are looking for a command line way to this, you&#8217;ll be happy to know you can use the <strong>lshw<\/strong> command for it.<\/p>\n<p>In this tutorial, we will discuss this utility using some easy to understand examples. But before we do that, it&#8217;s worth mentioning that all examples in this article have been tested on an Ubuntu 16.04 LTS machine.<\/p>\n<h2 id=\"linux-lshw-command\">Linux lshw command<\/h2>\n<p>As already mentioned, the lshw command lets you fetch hardware info. Here&#8217;s the syntax of the command:<\/p>\n<p class=\"command\">lshw [options]<\/p>\n<p>And here&#8217;s how the man page explains the tool:<\/p>\n<pre readability=\"13\"> lshw\u00a0 is\u00a0 a\u00a0 small tool to extract detailed information on the hardware<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 configuration of the machine. It can report exact memory configuration,<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 firmware version, mainboard configuration, CPU version and speed, cache<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 configuration, bus speed, etc. on DMI-capable x86 or IA-64 systems\u00a0 and<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 on some PowerPC machines (PowerMac G4 is known to work).<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 It\u00a0 currently\u00a0 supports\u00a0 DMI\u00a0 (x86 and IA-64 only), OpenFirmware device<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tree (PowerPC only), PCI\/AGP, CPUID (x86), IDE\/ATA\/ATAPI, PCMCIA\u00a0 (only<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tested on x86), SCSI and USB.<\/p><\/pre>\n<p>Following are some Q&amp;A-styled examples that will give you a better idea on how this utility works.<\/p>\n<h2 id=\"q-how-to-use-the-lshw-command\">Q1. How to use the lshw command?<\/h2>\n<p>For default usage, all you have to do is to run the &#8216;lshw&#8217; command without any options.<\/p>\n<p class=\"command\">lshw<\/p>\n<p>Note that you need to execute the lshw command with root privileges.<\/p>\n<p>Following is the output the command produced on my system:<\/p>\n<p><a class=\"fancybox\" id=\"img-lshw-default\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/lshw-default.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/linux-lshw-command-tutorial-for-beginners-6-examples.png\" alt=\"How to use the lshw command\" width=\"472\" height=\"550\" title=\"\"><\/a><\/p>\n<p>Please note that this is just a small part of the information produced in output.<\/p>\n<h2 id=\"q-how-to-have-device-tree-output-showing-hardware-paths\">Q2. How to have device tree output showing hardware paths?<\/h2>\n<p>For this, use the <strong>-short<\/strong> command line option.<\/p>\n<p class=\"command\">lshw -short<\/p>\n<p>Here&#8217;s the output the above command produced in my case:<\/p>\n<p><a class=\"fancybox\" id=\"img-lshw-short\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/lshw-short.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/linux-lshw-command-tutorial-for-beginners-6-examples-1.png\" alt=\"How to have device tree output showing hardware paths\" width=\"500\" height=\"262\" title=\"\"><\/a><\/p>\n<h2 id=\"q-how-make-lshw-fetch-scsi-usb-ide-and-pci-device-info\">Q3. How make lshw fetch SCSI, USB, IDE and PCI device info?<\/h2>\n<p>This info can be fetched using the -businfo option of the lshw command.<\/p>\n<p class=\"command\">lshw -businfo<\/p>\n<p>Here&#8217;s the output this command produced in my case:<\/p>\n<p><a class=\"fancybox\" id=\"img-lshow-businfo\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/lshow-businfo.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/linux-lshw-command-tutorial-for-beginners-6-examples-2.png\" alt=\"How make lshw fetch SCSI, USB, IDE and PCI device info\" width=\"500\" height=\"324\" title=\"\"><\/a><\/p>\n<p><strong>Note<\/strong>: You can use <em><strong>-numeric<\/strong><\/em> option if you want the tool to also display numeric IDs (for PCI and USB devices).<\/p>\n<h2 id=\"q-how-to-make-lshw-display-information-in-html-format\">Q4. How to make lshw display information in HTML format.<\/h2>\n<p>There&#8217;s a dedicated command line option for this: -html. So you can use the tool in the following way:<\/p>\n<p class=\"command\">lshw -html<\/p>\n<p>Here&#8217;s the output the above command produced on my system:<\/p>\n<p><a class=\"fancybox\" id=\"img-lshw-html\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/lshw-html.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/linux-lshw-command-tutorial-for-beginners-6-examples-3.png\" alt=\"How to make lshw display information in HTML format\" width=\"500\" height=\"425\" title=\"\"><\/a><\/p>\n<h2 id=\"q-how-to-make-display-information-in-xml-format\">Q5. How to make display information in XML format?<\/h2>\n<p>Like HTML output, lshw command can also produce output in the XML format, and the command line option that facilitates this is -xml.<\/p>\n<p class=\"command\">lshw -xml<\/p>\n<p>Here&#8217;s a sample output in this format:<\/p>\n<p><a class=\"fancybox\" id=\"img-lshw-xml\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/lshw-xml.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/linux-lshw-command-tutorial-for-beginners-6-examples-4.png\" alt=\"How to make display information in XML format\" width=\"500\" height=\"464\" title=\"\"><\/a><\/p>\n<p>Similarly, you can use the <em><strong>-json<\/strong><\/em> command line option to display the device tree as a JSON object.<\/p>\n<h2 id=\"q-how-to-make-lshw-not-emit-sensitive-info-in-output\">Q6. How to make lshw not emit sensitive info in output?<\/h2>\n<p>You&#8217;ll be glad to know lshw takes care of this requirement as well. Those who don&#8217;t want the tool to emit potentially sensitive information in output can use the <strong>-sanitize<\/strong> option. This way, you can avoid lshw emitting information like IP addresses, serial numbers, and more.<\/p>\n<p class=\"command\">lshw -sanitize<\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>As you&#8217;d agree, lshw is the not the command you&#8217;d require everyday. But it&#8217;s definitely a handy tool, for you never know when you might want to access your system&#8217;s hardware details. We discussed basic usage of the tool here &#8211; for more info, head to the command&#8217;s <a href=\"https:\/\/linux.die.net\/man\/1\/lshw\" target=\"_blank\" rel=\"noopener noreferrer\">man page<\/a>.<\/p>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The beauty of the Linux command line lies in the fact that you can do almost anything using the command line tools. Even if it involves fetching information on the system&#8217;s hardware components. If that&#8217;s what you intend to do, and are looking for a command line way to this, you&#8217;ll be happy to know [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-2946","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/2946","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=2946"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/2946\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=2946"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=2946"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=2946"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}