Hardware Utilities

How to Get Hardware Info on Linux

Linux users, especially administrators, need to know accurate information about the hardware platform they are using. This helps them in installing not only compatible software but also hardware components according to the system they are on. Linux has both built-in and easily installable commands that can be used to fetch the required system and hardware details. This article explains the usage of some of these commands to enable you in knowing all about your Linux system.

The commands mentioned in this article have been run on a Debian 10 Buster system but they can be replicated easily on most Linux distros.

We will be using the Debian command line, the Terminal, to fetch all the hardware information. You can open the Terminal application by entering the keywords ‘Terminal’ in the Application Launcher search as follows:

Use the Super/Windows key to access the Application Launcher.

Fetching Basic System Information through the Uname Command

The uname command, short for unix name, in Linux is used to print operating system and hardware information through the command line. Here is the syntax of the uname command:

$ uname [options]...

By using various option switches with the command, you can choose to print either all or some specific information about your system.

The default behavior of the uname command

When you use the uname command without any switch, it prints the Linux Kernel name running on your system. Here is how you would use the command:

$ uname

You can see how the uname command prints my Kernel name, which is Linux.

Printing Kernel Name through uname

Now, if you particularly want the uname command to print the Kernel name, you can use the -s switch with the command as follows:

$ uname -s

We need to use the -s option in the scenario where we want to print the Kernel name along with some other information by using more than one switch.

Printing Kernel Release through uname

If you want the uname command to print the Kernel release you are using, you can use the -r switch with the command as follows:

$ uname -r

You can see how the output prints the release number of the Linux kernel I am running.

Printing Kernel Version through uname

If you want the uname command to print the Kernel version you are using, you can use the v switch with the command as follows:

$ uname -v

You can see how the output prints the version number of the Linux kernel I am running.

Printing Machine Hardware Name through uname

Using the -m switch with the uname command prints the hardware name of your machine.

This lets you know the hardware architecture of your system.

$ uname -m

If you see x86_64 as the output, you are using a 64-bit machine. The output i686 indicates that you are using a 32-bit architecture.

Printing Network Node Hostname through uname

Using the -n switch with the uname command prints the node name/hostname of your system. The hostname is the identification that a system uses to communicate on a network.

$ uname -n

The output of the uname command with the -n switch is the same as that of the ‘hostname’ command.

Printing Processor Type through uname

You can use the uname command as follows with the -p switch in order to print the processor type:

$ uname -p

The above command did not produce a valid output on my Debian but it gives accurate information on Ubuntu.

Printing Hardware Platform through uname

The uname command with the -i switch is used to print the hardware platform you are on.

$ uname -i

The above command also did not produce a valid output on my Debian but it gives accurate information on Ubuntu.

Printing Operating System name through uname

The uname command with the -o switch prints the operating system name that you are running.

$ uname -o

The output of this command is GNU/Linux on all Linux distros.

Printing All the above information through uname

If you want the uname command to print all the information mentioned above, you can of course use the command with all the switches. The simple way, however, is to use only the -a switch with the uname command as follows:

$ uname -a

You can see how the output displays all the information we have printed above, one by one.

Fetch Detailed Hardware Information

In this section, we will explain some more commands through which you can print a complete picture of your hardware specifications and also that of some individual hardware components.

Fetching Hardware Picture through the lshw command

Lshw, short for list hardware, is a command line utility that is used to print information about the hardware components of your system. It fetches information like CPU type & speed, disks, memory, bus speed, firmware, cache, etc, from the /proc files. If your system does not have this utility installed by default, you can install it through the following command as an administrator:

$ sudo apt-get install lshw

You can then fetch a detailed hardware report through the following command:

$ sudo lshw

Running the command as sudo gives you access to the confidential information about the system.

If you are looking for a summary of the above information, you can get it through the following lshw usage:

$ sudo lshw -short

You can see how the command prints a better readable hardware profile in a column-wise format.

You can print the output of the lshw command to an html file for sharing or for later use.

Run the following command as sudo in order to do so:

$ sudo lshw -html > filename.html

The html is saved in the current user’s home folder by default and this is how it looks like:

Fetching CPU Information through lscpu

The lscpu command fetches detailed CPU information from the /proc/cpuinfo and sysfs files. This is the exact command you will be using:

$ lscpu

Fetching Block Device Information through lsblk

The lsblk command fetches detailed block device information such as your hard drives, flash drives, and their partitions. This is the exact command you will be using:

$ lsblk

For even more information, you can use the following command:

$ lsblk -a

Fetching USB Controllers Information through lsusb

The lsusb command fetches and prints detailed USB controllers information along with the connected hardware. This is the exact command you will be using:

$ lsusb

For even more information, you can use the following command:

$ lsusb -v

Here are some of the other commands you can use to get information about a particular kind of device:

Command Information
$ lspci Fetch information about PCI devices connected to your system
$ lsscsi Fetch information about SCSI devices connected to your system
$ hdparm [device_location] Fetch information about SATA devices connected to your system. For example, use the command $ hdparm /dev/sda1 for information about sda 1

This was all you needed to know about printing all or specific system and hardware information on your Linux.

About the author

Karim Buzdar

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn.