Linux command line to get hardwar informations

How To Get Hardware Details Information On Linux

On this article we will discuss how to use the command line to get hardware details information from our server using vmstat, lshw, uname, top and htop command line.

If we are going to deploy or install a new application on a system, we need system and hardware detail information from that device. This is to ensure a suitable configuration for both the application and the system itself.  As an example we will install oracle database on a server, we need detailed information from the hardware and configuration of the existing kernel.  Usually we will ensure the size of disk space, memory, CPU core and OS kernel used.

In this article, we will discuss how to extract the hardware and system  information details from the computer we are using. We will use the command line that is already available on our Ubuntu system. Currently, we use Linux Ubuntu 20.04 LTS Focal Fossa. Some command lines that we will use are uname, vmstat, lshw, top.

vmstat (virtual memory statistics) Command Line

vmstat is the command line that reports virtual memory statistics, it gives information about processes, memory, paging, block IO, traps, disks and cpu activity. This command line can specify a sampling interval which permits observing system activity in near-real time. It helps us (System Administrator) to collect memory server information in case the anomaly happened on the system and will take a appropriate decision.

vmstat command line has several option.

  • -a, –active. Display active and inactive memory, given a 2.5.41 kernel or better.
  • -f, –forks. The -f switch displays the number of forks since boot. This includes the fork, vfork, and clone system calls, and is equivalent to the total number of tasks created. Each process is represented by one or more tasks, depending on thread usage. This display does not repeat.
  • -m, –slabs. Displays slabinfo.
  • -n, –one-header. Display the header only once rather than periodically.
  • -s, –stats. Displays a table of various event counters and memory statistics. This display does not repeat.
  • -d, –disk. Report disk statistics (2.5.70 or above required).
  • -D, –disk-sum. Report some summary statistics about disk activity.
  • -p, –partition device. Detailed statistics about partition (2.5.70 or above required).
  • -S, –unit character. Switches outputs between 1000 (k), 1024 (K), 1000000 (m), or 1048576 (M) bytes. Note this does not change the block (bi/bo) fields, which are always measured in blocks.
  • -t, –timestamp.

Here is the example of vmstat command line.

lshw Command Line

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, CPU version and speed, cache configuration, bus speed, etc. on DMI-capable x86 or IA-64 systems and on some PowerPC machines (PowerMac G4 is known to work).

By submitting lshw command line, we will get details hardware configuration of our machine. The lswh is requires root privilege to be executed. So we need root or sudoer user for it.

ramans@otodiginet:/$ sudo lshw
[sudo] password for ramans:
description: Computer
product: VMware Virtual Platform
vendor: VMware, Inc.
version: None
serial: VMware-56 4d c3 d5 75 ed 72 78-71 22 98 08 9a a5 9d be
width: 64 bits
capabilities: smbios-2.7 dmi-2.7 smp vsyscall32
configuration: administrator_password=enabled boot=normal frontpanel_password=unknown keyboard_password=unknown power-on_password=disabled uuid=564DC3D5-75ED-7278-7122-98089AA59DBE
description: Motherboard
product: 440BX Desktop Reference Platform
vendor: Intel Corporation
physical id: 0
version: None
serial: None
description: BIOS
vendor: Phoenix Technologies LTD

uname Command Line

The uname command line is used to print system information. There are several option on this command, namely :

-a, –all. Print all information, in the following order, except omit -p and -i if unknown
-s, –kernel-name. print the kernel name
-n, –nodename. Print the network node hostname
-r, –kernel-release. print the kernel release
-v, –kernel-version. Print the kernel version
-m, –machine. Print the machine hardware name
-p, –processor. Print the processor type (non-portable)
-i, –hardware-platform. Print the hardware platform (non-portable)
-o, –operating-system. Print the operating system
–help. Display this help and exit
–version. Output version information and exit

Example is as follow.

ramans@otodiginet:/$ uname --version
uname (GNU coreutils) 8.30
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by David MacKenzie.
ramans@otodiginet:/$ uname -a
Linux otodiginet 5.4.0-37-generic #41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
ramans@otodiginet:/$ ramans@otodiginet:/$ uname -s
ramans@otodiginet:/$ uname -n
ramans@otodiginet:/$ uname -r
ramans@otodiginet:/$ uname -v
#41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020
ramans@otodiginet:/$ uname -m
ramans@otodiginet:/$ uname -p
ramans@otodiginet:/$ uname -i
ramans@otodiginet:/$ uname -o
uname command line on Linux

top Command Line

The top command line is used to display Linux processes. The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of processes or threads currently being managed by the Linux kernel. The types of system summary information shown and the types, order and size of information displayed for processes are all user configurable and that configuration can be made persistent across restarts.

top command on linux

htop command line

The htop command line is an ncurses-based process viewer similar to top, but it allows one to scroll the list vertically and horizontally to see all processes and their ull command lines. Tasks related to processes (killing, renicing) can be done without entering their PIDs. This command line is not Linux defautl OS, so we have to install it first to use this application. The hop installation using snap.

ramans@otodiginet:/$ sudo snap install htop
[sudo] password for ramans:
htop 2.2.0 from Maximiliano Bertacchini (maxiberta) installed
Here is the htop command line output example.

For executing htop command line we submitting.

ramans@otodiginet:/$ htop
locales-launch: Data of en_US locale not found, generating, please wait…


The Linux OS has informative command line to help us knowing the hardware details information. These command lines can be used with ordinary username/account and need root privilege or sudo privilege.

Share this article via :

Leave a Reply

Your email address will not be published. Required fields are marked *