18 Useful Commands to Get Hardware Information on Linux

How to show and gather hardware details from Terminal Ubuntu, Elementary, Mint, Debian or any other Linux distro - Without a doubt, Command Line Interface or CLI is really really really important things you should know while learning Linux OS. It's fast and powerful way to perform any operations.

One of them is a Linux command to get hardware info such as CPU, Memory / RAM, Disk, and its kind. Basically, there are two options you can do to see your PC/laptop hardware information. It's GUI and CLI based approach.

For Linux hardware info GUI based, you can go with programs such as System Monitor, and hardinfo. How about Command line based? It may a bit confusing for new user right?

Commands to check hardware information

That is the point! I will show you some useful Linux command to get hardware specs, configuration, info, type, of various hardware and peripherals.

1. lshw

Show hardware details on terminal Linux

lshw is a small tool to extract detailed information on the hardware configuration of the machine. It can report exact memory configuration, firmware version, mainboard configuration, processor info, version and speed, cache configuration, bus speed, etc.

2. lscpu

lscpu get hardware info on terminal Linux

lscpu gathers CPU architecture information from your system, precisely from sysfs and cpuinfo that placed in /proc. The information includes, the number of CPUs, threads, cores, sockets, and Non-Uniform Memory Access (NUMA) nodes.

There is also information about the CPU caches and cache sharing, family, model, bogoMIPS, byte order, and stepping. Not all columns are supported on all architectures. If an unsupported column is specified, lscpu prints the column but does not provide any data for it.

3. lspci

lspci collect hardware info on terminal Linux

lspci is a utility for displaying information about PCI buses in the system and devices connected to them. By default, it shows a brief list of devices. Use the options described below to request either a more verbose output or output intended for parsing by other programs.

You can combine the command with pipeline "|" and grep to prints the matching lines, e.g :

lspci | grep RAM
lspci | grep VGA
lspci | grep USB
lspci | grep Audio
lspci | grep Ethernet
lspci | grep Network

4. lsusb

lsusb see usb flash drive, modem, mouse command terminal linux

Similar with the name, lsusb is a utility for displaying information about USB buses in th system and the devices connected to them such as USB Mouse, USB Flash Drive, and USB modem. This command can print out the name of vendor's / product's ID.

This tool is really important to setup our USB modem ( if it doesn't detected on your Linux ), and Android Rules When Installing ADB and Fastboot on Ubuntu Linux.

5. lsblk

Linux command to view disk space

lsblk lists information about all available or the specified block devices. The lsblk command reads the sysfs filesystem and udev db to gather information. The command prints all block devices (except RAM disks) in a tree-like format by default.

6. fdisk

Linux show physical disks terminal

fdisk command is a dialog-driven program for creation and manipulation of partition tables. It understands GPT, MBR, Sun, SGI and BSD partition tbale. The basic usage ( Please use sudo to run the command ) :

fdisk [options] -l [<disk>] list partition table(s)

7. dmidecode

System Information Linux Command

dmidecode is a tool for dumping a computer's DMI (some say SMBIOS) table contents in a human-readable format. This table contains a description of the system's hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision.

Keywords can be used instead of type numbers with --type. Each keyword is equivalent to a list of type numbers:

Keyword     Types
bios        0, 13
system      1, 12, 15, 23, 32
baseboard   2, 10, 41
chassis     3
processor   4
memory      5, 6, 16, 17
cache       7
connector   8
slot        9

The DMI table doesn't only describe what the system is currently made of, it also can report the possible evolutions ( such as the fastest supported CPU or the maximal amount of memory supported ).

# sudo dmidecode -t 5
Getting SMBIOS data from sysfs.
SMBIOS 2.7 present.

Handle 0x0005, DMI type 5, 24 bytes
Memory Controller Information
 Error Detecting Method: None
 Error Correcting Capabilities:
 Supported Interleave: One-way Interleave
 Current Interleave: One-way Interleave
 Maximum Memory Module Size: 8192 MB
 Maximum Total Memory Size: 32768 MB
 Supported Speeds:
 Supported Memory Types:
 Memory Module Voltage: Unknown
 Associated Memory Slots: 4
 Enabled Error Correcting Capabilities:

8. df

Show linux mount partition

df displays the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown.

If an argument is the absolute file name of a disk device node containing a mounted file system, df shows the space available on that file system rather than on the file system containing the device node. Use -h to make it human-readable.

9. Mount

Mount partition and umount partition from terminal

Mount command is used to mount, unmount and view mounted file system. The standard form of the mount command is :

mount -t type device dir

9.1 How to mount a partition from terminal?

You can use the following command to mount the partition :

sudo mount /dev/sda3 /media/tiwo/Linuxslaves/

The command above will mount the sda3 to /media/tiwo/Linuxslaves. Of course you need change /media/tiwo/Linuxslaves/ with your path.

9.2 How to unmount a parition from terminal?

Run the command below to unmount file system :

sudo umount /dev/sda3

If you're have dualboot computer with Windows installed, and need to automount windows partitions you can read our post at How To Automount Windows : NTFS Partition On Linux.

10. hdparm

Show sata/pata/sas linux command

hdparm provides a command line interface to various kernel interfaces supported by the Linux SATA/PATA/SAS "libata" subsystem and the older IDE driver subsystem.

11. /proc files

The /proc directory contain information about hardware and configurations such as CPU, memory, kernel version, disk information and etc.
  • cat /proc/cpuinfo : Display cpu info.
  • cat /proc/meminfo : Display memory info.
  • cat /proc/version : Display kernel version.
  • cat /proc/partitions : Display partition.
  • cat /proc/swaps : Display swap partition.
  • cat /proc/scsi/scsi : Display SCSI/Sata devices.

12. free

How much ram used command Linux terminal

This will displays the total amount of free and used physical and swap memory in the system, as well as the buffers and caches used by the kernel. The The displayed columns are including :
  • Total installed memory
  • How much ram used
  • Free / unused memory
  • Shared
  • Buffers
  • Cache
  • Available

The default, it display the amount memory in kilobytes. You can run free with some options :
  1. -b, --bytes : bytes.
  2. -k, --kilo : kilobytes ( This is the default )
  3. -m, --mega : megabytes.
  4. -g, --giga : gigabytes.
  5. -h, --human : Show all output fields automatically scaled to shortest 3 digit unit and display the units of print out.

Not Installed By The Default

The tool that listed below is not installed by default on Ubuntu, so you must install it yourself. You can install it by typing the following command :

sudo apt-get install <package_name>

If you need a quick way to run Linux command, why not using bash aliases? It can save your time rather than typing one-by-one. Read Bash Aliases : Create Linux Command Line Shortcut.

Let's start it up!

13. lsscsi

Linux show physical disks command

lsscsi will list SCSI devices (or hosts) and their attributes. It uses information in sysfs (Linux kernel series 2.6 and later) to list SCSI devices (or hosts) currently attached to the system.

By the default it isn't installed on Ubuntu system. Run the following command to install lsscsi :

sudo apt-get install lsscsi

Options can be used to control the amount and form of information provided for each device.

14. inxi

shows system hardware, CPU, drivers, Xorg, Desktop, Kernel, GCC version, Processes, RAM usage

inxi is a command line system info script built for for console and IRC. It is also used for forum technical support, as a debugging tool, to quickly ascertain user system configuration and hardware.

This tools will shows system hardware, CPU, drivers, Xorg, Desktop, Kernel, GCC version, Processes, RAM usage, and a wide variety of other useful information. inxi output varies between CLI and IRC, with some default filters and color options applied to IRC use.

There are some options to get more details :
  • -P : Show full partition information
  • -A :  Show Audio/sound card information
  • -C :  Show full CPU output, including per CPU clockspeed and CPU max speed if available
  • -D :  Show full hard Disk info, not only model, ie:  /dev/sda ST380817AS 80.0GB. Shows disk space total + used percentage.The disk used percentage includes space used by swap partitions.
  • -G :  Show Graphic card information. Cards, Display Server (vendor and version number)
  • -m :  Memory (RAM) data.

For full option, you can add -h run open help menu :

inxi -h

inxi can be used to show Wan IP address, and shows local interfaces. You just need to add option -i to get the information.

# inxi -i
Network:   Card-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
           driver: r8169
           IF: enp1s0 state: down mac: XX:XX:XX:XX:XX:XX
           Card-2: Qualcomm Atheros QCA9565 / AR9565 Wireless Network Adapter
           driver: ath9k
           IF: wlp2s0 state: down mac: XX:XX:XX:XX:XX:XX
           Card-3: Atheros AR9271 802.11n
           IF: null-if-id state: N/A mac: N/A
           WAN IP: XX.XX.XX.180 IF: wlxxxxxxxxxxxxx ip-v4: XX.XXX.XXX.XXX
           IF: wlp2s0 ip-v4: N/A IF: enp1s0 ip-v4: N/A

15. pydf

Linux mount partition command terminal

pydf is a python script that displays the amount of disk space available on the mounted filesystems, using different colours for different types of filesystems.

For Ubuntu Linux user and derivatives system ( Mint, Elementary ), you can install pydf by typing and run the command below :

sudo apt-get install pydf

BUGS : When running with python3, mountpoints with out-of-locale non ASCII names will not be displayed (due to inability of os.statvfs to use bytes instead of strings).

16. hwinfo

Linux hardware details command

hwinfo is used to probe for the hardware present in the system. It can be used to generate a system overview log which can be later used for support. The --short option will show only a summary. Use this option in addition to a hardware probing option.

17. screenfetch, Linux OS Info

Screenfetch, display details information in terminal Linux

This handy Bash script can be used to generate one of those nifty terminal theme information + ASCII distribution logos you see in everyone's screenshots nowadays.

It will auto-detect your distribution and display an ASCII version of that distribution's logo and some valuable information to the right. There are options to specify no ASCII art, colors, taking a screenshot upon displaying info, and even customizing the screenshot command!

Install screenfetch on Ubuntu 14.04 LTS, 16.04 LTS, Linux Mint, Elementary OS and Debian ( stable/testing/unstable ) :

sudo apt-get install screenfetch

17.1 Supported GNU/Linux Distributions

It supports many popular linux distros such as Antergos, Arch Linux (Old and Current Logos), BLAG, CentOS, Chakra, Chapeau, CrunchBang, CRUX, Debian, Deepin, Dragora, elementary OS, Evolve OS, Fedora, Frugalware, Fuduntu, Funtoo, Gentoo, gNewSense, Jiyuu Linux, Kali Linux, KaOS, Korora, LinuxDeepin, Linux Mint, LMDE, Logos, Mageia, Mandriva/Mandrake, Manjaro, NixOS, openSUSE, Parabola GNU/Linux-libre, PeppermintOS, Raspbian, Red Hat Enterprise Linux, Sabayon, ScientificLinux, Slackware, SolusOS, TinyCore, Trisquel, Ubuntu, Viperr and Void.

17.2 Supported Desktop Managers

KDE, Gnome, Unity, Xfce, LXDE, Cinnamon, MATE, CDE and RazorQt.

17.3 Supported Window Managers

2bwm, 9wm, Awesome, Beryl, Blackbox, Cinnamon, Compiz, dminiwm, dwm, dtwm, E16, E17, echinus, Emerald, FluxBox, FVWM, herbstluftwm, IceWM, KWin, Metacity, monsterwm, Musca, Gala, Mutter, Muffin, Notion, OpenBox, PekWM, Ratpoison, Sawfish, ScrotWM, SpectrWM, StumpWM, subtle, WindowMaker, WMFS, wmii, Xfwm4, XMonad and i3.

18. archey

Archey is a script that displays system info in the terminal with a logo of this the Linux distro in ASCII art. It was originally written for Arch Linux but the current version of archey supports many other popular linux distros like Debian, Ubuntu, Linux Mint, Fedora, Archbang, and etc.

Install archey on Ubuntu and Derivatives system

Run the following command to install archey in Ubuntu and other Debian-based distros like Linux Mint :

sudo apt-get install lsb-release scrot
sudo dpkg -i archey-0.2.8.deb

Linux Tips

There are some tips we will tell you to learn Linux and work with terminal, all of them have posted in Linuxslaves. They are :
  1. 26 Useful Linux Terminal Keyboard Shortcuts You Must Know
  2. Basic Commands of APT-GET and APT-CACHE for Package Management

That's all I can write about a command to find hardware details and to know the hardware components of your Linux system is running on with additional tools you can install. If you have other way please feel free tell us with the comments. Thanks for visiting us!.