Collecting Ubuntu Linux System Hardware Information

For new computer or Laptop or server, I need to collect the information about its hardware. This is also useful when you need to replace a disk or memory with a vendor. In order to replace hardware you need all information in advance. In this post, I’m going to list commands that you can use to collect the hardware information.
Ubuntu Linux Server Collecting System Information

All of the following commands are tested on Ubuntu Linux LTS 16.04/18.04/20.04 and 22.04, but should work with any modern Linux distro too such as Debian, Fedora Linux and more.

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Linux terminal
Category System Management
OS compatibility Debian Linux Mint Ubuntu
Est. reading time 14 minutes

Find the system host name

Display the system’s host name using the hostnamectl command/hostname command:
$ hostname
$ cat /etc/hostname

Display the Ubuntu Linux system’s DNS domain name:
$ dnsdomainname

Show the Ubuntu system’s Fully Qualified Domain Name (FQDN):
hostname -f

The following Ubuntu command gives better output. For example:
$ hostnamectl

   Static hostname: wks01
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: f20d8ece72ff48a689d69b86b73aa9f7
           Boot ID: fee08b5baf434304a7e687b41b89c4c1
  Operating System: Ubuntu 20.04.5 LTS
            Kernel: Linux 5.15.0-46-generic
      Architecture: x86-64

Find the system serial number, manufacturer of the Ubuntu Linux system and model name

Use the dmidecode command as follows:
$ sudo dmidecode -s system-serial-number
$ sudo dmidecode -s system-manufacturer
$ sudo dmidecode -s system-product-name
$ sudo dmidecode | more

OR use the lshw command:
# lshw | more
$ sudo lshw -short

H/W path               Device          Class          Description
                                       system         20QVCTO1WW (LENOVO_MT_20QV_BU_Think_FM_ThinkPad X1 Extreme 2nd)
/0                                     bus            20QVCTO1WW
/0/3                                   memory         32GiB System Memory
/0/3/0                                 memory         32GiB SODIMM DDR4 Synchronous 2667 MHz (0.4 ns)
/0/10                                  processor      Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz
/0/11                                  memory         128KiB BIOS
/0/100                                 bridge         8th Gen Core Processor Host Bridge/DRAM Registers
/0/100/1                               bridge         Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16)
/0/100/1/0                             display        TU117M [GeForce GTX 1650 Mobile / Max-Q]
/0/100/1/0.1                           multimedia     NVIDIA Corporation
/0/100/4                               generic        Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Thermal Subsystem
/0/100/8                               generic        Xeon E3-1200 v5/v6 / E3-1500 v5 / 6th/7th/8th Gen Core Processor Gaussian Mixture Model
/0/100/12                              generic        Cannon Lake PCH Thermal Controller
/0/100/14                              bus            Cannon Lake PCH USB 3.1 xHCI Host Controller
/0/100/14/0            usb1            bus            xHCI Host Controller
/0/100/14/0/1                          input          Microsoft Ergonomic Keyboard
/0/100/14/0/4                          bus            USB2.0 Hub
/0/100/14/0/4/4                        bus            USB 2.0 Hub
/0/100/14/0/4/4/1                      generic        USB 2.0 BILLBOARD
/0/100/14/0/9                          generic        Generic USB device
/0/100/1b/0                            storage        NVMe SSD Controller SM981/PM981/PM983
/0/100/1b/0/0          /dev/nvme0      storage        SAMSUNG MZVLB1T0HBLR-000L7
/0/100/1b/0/0/1        /dev/nvme0n1    disk           1024GB NVMe namespace
/0/100/1b/0/0/1/1                      volume         511MiB Windows FAT volume
/0/100/1b/0/0/1/2      /dev/nvme0n1p2  volume         1465MiB EXT4 volume
/0/100/1b/0/0/1/3      /dev/nvme0n1p3  volume         951GiB EFI partition
/0/100/1b.4                            bridge         Cannon Lake PCH PCI Express Root Port #21
/0/100/1d.6/0          wlp82s0         network        Wi-Fi 6 AX200
/0/100/1e                              communication  Cannon Lake PCH Serial IO UART Host Controller
/0/100/1f                              bridge         Intel Corporation
/0/100/1f.3                            multimedia     Cannon Lake PCH cAVS
/0/100/1f.4                            bus            Cannon Lake PCH SMBus Controller
/0/100/1f.5                            bus            Cannon Lake PCH SPI Controller
/0/100/1f.6            enp0s31f6       network        Ethernet Connection (7) I219-LM
/2                     virbr0-nic      network        Ethernet interface

Ubuntu show information about installed hardware

The lsdev command gathers information about Ubuntu Linux computer’s installed hardware from the interrupts, ioports, and dma files in the /proc/ or /sys/ directory. Hence, you get a quick overview of which Linux hardware uses what I/O addresses, IRQ and DMA channels. But, first, use the apt-get command or apt command to install lsdev:
sudo apt install procinfo
$ sudo lsdev

Find the system CPU info

Use the cat command to query the /proc/cpuinfo:
$ cat /proc/cpuinfo
Of course, there is an easy to use the lscpu command:
$ lscpu

Display CPU (processors) related statistics

Try the following commands to get info about available processor, starting from first one (numbered as 0). For instance:
$ sudo mpstat
$ sudo mpstat 1
$ sudo mpstat -A

Find the system main memory (RAM) info

Show statistics about memory usage on the system including total installed and used RAM. For example:
$ less /proc/meminfo
Show amount of free and used memory in the Ubuntu Linux system:

## Display the amount of memory in megabytes ##
free -m
## Display the amount of memory in gigabytes ##
free -g 
## Display the amount of memory in terabytes ##
free --tera
## Display human readable output ##
free -h

Show the Ubuntu Linux system swap space usage

Try the following swapon command and other commands:
$ swapon -s
$ cat /proc/swaps
$ cat /proc/meminfo
$ top
$ vmstat
$ for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less
$ smem

See my page “How To Check Swap Usage Size and Utilization in Linux” for more info.

Show the system virtual memory statistics

Use the vmstat command command on Ubuntu server:
$ sudo vmstat
$ sudo vmstat 1
$ sudo vmstat 2

Finding the Ubuntu Linux distribution version and related information

Try the lsb_release command and other commands to check Ubuntu Linux version as follows:
$ lsb_release -a
Sample output indicating that I am using Ubuntu Linux 20.04.05 LTS:

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.5 LTS
Release:	20.04
Codename:	focal

Find the system kernel version number on Ubuntu

Type the uname command:
$ uname -r
$ uname -a

Finding the Ubuntu system kernel parameters

You need to query and print contains of the /proc/cmdline using the cat command (or use the bat command if you want to see fancy outputs):
$ cat /proc/cmdline
$ sysctl -a | more

Here is what I see:

 BOOT_IMAGE=/vmlinuz-5.15.0-46-generic root=/dev/mapper/vgubuntu-root ro quiet splash vt.handoff=7

Finding the system kernel architecture (32 bit or 64 bit)

Try the following commands:
$ uname -m
$ getconf LONG_BIT
$ arch

The 64 outputs measn I am using 64 bit CPU.

Find the system disk information

Show all installed disks and size using the following commands:
# fdisk -l | grep '^Disk /dev'

Listing all Linux partitions of disk named /dev/sda disk:

To read a disk label for /dev/sda:
# fdisk -l /dev/sda
To label a disk:
$ sudo fdisk /dev/sda
$ sudo e2label /dev/sda1
$ sudo cfdisk /dev/sda

Show block device attributes:

Try the blkid command:
# blkid

List all block devices:

Use the lsblk command on Ubuntu:
# lsblk

Display file system disk space usage:

Try the df command:
$ df
$ df -H
$ df -HT

Estimate file space usage:

Use the du command:
$ du
$ du /home

Display mounted file system on Ubuntu:

Use the following mount command:
$ cat /proc/mount
$ mount
# filter out result #
$ mount | grep 'ext4'

/dev/mapper/vgubuntu-root on / type ext4 (rw,relatime,errors=remount-ro)
/dev/nvme0n1p2 on /boot type ext4 (rw,relatime)

Display SCSI devices (or hosts) and their attributes on Linux:

Use the lsscsi command:
$ lsscsi

Display I/O statistics

Try the iostat command $ sudo iostat
$ sudo iostat 2

See “How do I find out Linux Disk utilization and I/O usage?” page for further infomation about disk I/O under Linux.

Finding out the system PCI devices information

Try the lspci command:
$ lspci
$ lspci -vt
$ lspci | grep -i 'something'
$ lspci -vvvn| less

Find the system USB devices information

Use the lsusb command:
$ lsusb
[nixuer]lsusb -vt

/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 10000M
    ID 1d6b:0003 Linux Foundation 3.0 root hub
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 5000M
        ID 2109:0813 VIA Labs, Inc. 
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/10p, 10000M
    ID 1d6b:0003 Linux Foundation 3.0 root hub
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/16p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    |__ Port 1: Dev 2, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
        ID 045e:082c Microsoft Corp. 
    |__ Port 1: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
        ID 045e:082c Microsoft Corp. 
    |__ Port 4: Dev 3, If 0, Class=Hub, Driver=hub/4p, 480M
        ID 2109:2813 VIA Labs, Inc. 
        |__ Port 4: Dev 5, If 0, Class=Hub, Driver=hub/4p, 480M
            ID 1a40:0101 Terminus Technology Inc. Hub
            |__ Port 1: Dev 7, If 0, Class=, Driver=, 480M
                ID 2109:0102 VIA Labs, Inc. 
    |__ Port 9: Dev 4, If 0, Class=Vendor Specific Class, Driver=, 12M
        ID 06cb:00bd Synaptics, Inc. 
    |__ Port 14: Dev 6, If 0, Class=Wireless, Driver=btusb, 12M
        ID 8087:0029 Intel Corp. 
    |__ Port 14: Dev 6, If 1, Class=Wireless, Driver=btusb, 12M
        ID 8087:0029 Intel Corp. 

Find the system Wireless devices information

Try the following commands:
$ iwconfig
$ watch -n 1 cat /proc/net/wireless
$ wavemon

See the following tutorials for more info:

Find the system VGA/Graphics devices information

Want to see Linux GPU info? Try:
$ lspci | grep -i vga
$ lspci -vvnn | grep VGA

$ sudo lshw -class display

Find the system NVIDIA Graphics devices information

The following commands only works with Nvidia’s binary Linux driver:
$ nvidia-smi
$ nvidia-settings

Find the system AMD/ATI Graphics devices information

The following command only works with AMD’s binary Linux driver called catalyst:
$ fglrxinfo

Which version of Unity am I running?

$ unity --version
However, unity is no loger default on the Ubuntu desktop. Therefore, try the following command to print GNOME version:
$ gnome-shell --version
Look like I am using version 3.36.9:

GNOME Shell 3.36.9

Find the system audio devices information

Use the following commands:
$ lspci | grep -i audio
$ cat /proc/asound/cards
$ arecord -l
It seems I have Intel audio device:

**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: CX8070 Analog [CX8070 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Display the system/laptop battery status & thermal temperature on Ubuntu Laptop

$ upower -i /org/freedesktop/UPower/devices/battery_BAT0
$ acpi -V

Finding out how long the Linux system has been running

Use the uptime command/w, or who command as follows:
$ uptime
$ who
$ w

My Ubuntu 22.04 LTS server is up and running for 17 days:

 11:42:48 up 17 days, 15:18,  0 users,  load average: 0.00, 0.00, 0.00

Find the system load

Again use the following commands:
$ uptime
$ cat /proc/loadavg
$ sudo top
$ sudo htop
$ sudo atop

Show the system reboot and shutdown history

Use any one of the following last command:
$ last reboot
$ last shutdown

Show Ubuntu Linux system runlevel

Use the who/runlevel command as follows:
$ runlevel
$ who -r

On the latest version of Ubuntu use the systemctl command due to systemd as init:
$ systemctl get-default

Display kernel ring buffer (boot time) messages

Use the following command to see boot time message including hardware configuration
$ sudo less /var/log/dmesg
$ sudo grep 'regx' /var/log/dmesg
$ sudo grep '[h|s]d' /var/log/dmesg

Display the system drivers (modules)

We use the lsmod command as follows:
$ sudo lsmod
$ sudo modinfo {driver_name}
$ sudo modinfo kvm

Find the system IP address and related information

You need to use the ip command:

## Info about all interfaces. Must be run as root via sudo command ##
sudo ip a
sudo ip 
sudo ip link ls up
sudo ifconfig -a
## Only show eth1 interface info ##
sudo ip a show eth0
sudo ifconfig eth0

Display the system routing table

## You can use any one of the following command ##
## Must be run as root ##
sudo ip r
sudo route -n
sudo netstat -nr

Display Ubuntu Linux system’s Ethernet bridge

$ sudo brctl show
$ sudo bridge link

Display the system DNS server and related information for Ubuntu box

Show the system name server IP address (ISP or your dns server IP should be listed here):
$ cat /etc/resolv.conf
Display the system resolver configuration file. This is useful to find out how host lookups are to be performed:
$ cat /etc/host.conf
Use above two files to configure name resolution. However, on latest version of Ubuntu one can use the resolvectl command as follows:
$ resolvectl status
$ resolvectl status {interface_name}
$ resolvectl status enp0s31f6

Link 2 (enp0s31f6)
      Current Scopes: DNS          
DefaultRoute setting: yes          
       LLMNR setting: yes          
MulticastDNS setting: no           
  DNSOverTLS setting: no           
      DNSSEC setting: no           
    DNSSEC supported: no           
  Current DNS Server:
         DNS Servers:
          DNS Domain: ~.   

Display information about the system ports and socket

You need to use the ss command to display info about established or connected TCP and UDP ports on Ubuntu. For example:

## Must run as root via sudo ##
sudo ss
## Display all listing ports ##
sudo ss -l
sudo netstat -tulpn
sudo netstat -tulpn | grep LISTEN
## Display all TCP sockets
sudo ss -t -a
## Display all UDP sockets.
sudo ss -u -a
## List all open files
lsof | more
lsof | grep something
lsof /dev/sda2
lsof /path/to/file

Display the list of running services under Ubuntu Linux

Use the systemctl command:
$ sudo systemctl | more
$ sudo systemctl --type=service

Older Ubuntu Linux versiont try:
### SYS V ###
$ sudo service --status-all

$ sudo initctl list

Find out if service is enabled:

Again use the systemctl command:
$ sudo systemctl status {service-name}
# Finding out Nginx server status #
$ sudo systemctl status nginx.service

 nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-09-03 09:07:59 UTC; 3 days ago
       Docs: man:nginx(8)
    Process: 2190384 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=0/SUCCESS)
   Main PID: 1181 (nginx)
      Tasks: 5 (limit: 19182)
     Memory: 215.3M
     CGroup: /system.slice/nginx.service
             ├─   1181 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ├─2190388 nginx: worker process
             ├─2190389 nginx: worker process
             ├─2190390 nginx: worker process
             └─2190391 nginx: worker process

Sep 04 00:00:01 www-1 systemd[1]: Reloading A high performance web server and a reverse proxy server.
Sep 04 00:00:01 www-1 systemd[1]: Reloaded A high performance web server and a reverse proxy server.
Sep 05 00:00:01 www-1 systemd[1]: Reloading A high performance web server and a reverse proxy server.
Sep 05 00:00:01 www-1 systemd[1]: Reloaded A high performance web server and a reverse proxy server.
Sep 05 00:00:02 www-1 systemd[1]: Reloading A high performance web server and a reverse proxy server.
Sep 05 00:00:02 www-1 systemd[1]: Reloaded A high performance web server and a reverse proxy server.
Sep 06 00:00:01 www-1 systemd[1]: Reloading A high performance web server and a reverse proxy server.
Sep 06 00:00:01 www-1 systemd[1]: Reloaded A high performance web server and a reverse proxy server.
Sep 06 00:00:01 www-1 systemd[1]: Reloading A high performance web server and a reverse proxy server.
Sep 06 00:00:01 www-1 systemd[1]: Reloaded A high performance web server and a reverse proxy server.

Older Ubuntu version user, try:
$ sudo initctl status service-name
$ sudo initctl status smbd

## SYS V
$ sudo service serviceName status
$ sudo service nginx status

Linux view log files

Use the following commands to view log files on Linux:
$ cd /var/log
$ ls -l
$ tail -f /var/log/fileName
$ grep 'something' /var/log/fileNameHere

Finding file by name

Use the locate command $ locate fileName
$ locate htpasswd
$ locate passwd
$ locate my.resume.doc

Find file by given condition

Use the find command:
$ find {/dir/to/search} -name {file-to-search} -print
$ find /etc/ -name /etc/passwd -print
$ find $HOME -name '*.doc' -print

See Ubuntu Linux user account details

Query the /etc/passwd as follows:
$ less /etc/passwd
$ grep userName /etc/passwd
$ getent passwd

View group account details

Again, query the /etc/group using the grep command as follows:
$ less /etc/group
$ getent group
$ grep group-name-here /etc/group
$ groups userName

View Ubuntu Linux user account password policy

Type the chage command as follows:
$ chage -l userName
$ chage -l root
$ chage -l vivek

Last password change					: Mar 21, 2022
Password expires					: never
Password inactive					: never
Account expires						: never
Minimum number of days between password change		: 0
Maximum number of days between password change		: 99999
Number of days of warning before password expires	: 7

Viewing Ubuntu system usage

Try the following commands:
$ sudo top
$ sudo htop
$ sudo atop
$ sudo ps auxwww
$ sudo netstat [options] $ sudo iostat
$ sudo mpstat 1
$ sudo sar [options]

Tracing system call on Ubuntu machine

$ strace -o output.txt /bin/foo
$ strace -p 22254 -s 80 -o debug.nginx.txt

Trace library call on Ubuntu

$ sudo ltrace /usr/sbin/httpd
$ sudo ltrace /sbin/chroot /usr/sbin/httpd

View process info on Ubuntu box

Use the pstree command, ps command, and lsof command as follows:
$ sudo pstree
$ sudo pstree | less
$ sudo ps auxwwwm
$ ps alxwww
$ ps auxwww
$ lsof -b M -n -l

Ubuntu Linux changing process priority using the nice/renice

The syntax is as follows:
$ sudo /bin/nice -n -1 command-name-here
$ sudo /bin/nice -n -1 pid
$ sudo renice {priority} pid

View Linux process's CPU affinity

Try the taskset command as follows:
$ sudo taskset -p {pid-here}
$ sudo taskset -p 42

Display the system listing of all package installed

Use the dpkg command or apt-get command/apt command as follows:
$ dpkg -l
$ dpkg -l | less
$ dpkg -l nginx
$ apt list --installed
$ apt list --installed | more

accountsservice/focal-updates,focal-security,now 0.6.55-0ubuntu12~20.04.5 amd64 [installed,automatic]
acl/focal,now 2.2.53-6 amd64 [installed,automatic]
acpi-support/focal,now 0.143 amd64 [installed,automatic]
acpi/focal,now 1.7-1.1 amd64 [installed]
acpid/focal,now 1:2.0.32-1ubuntu1 amd64 [installed,automatic]
acpitool/focal,now 0.5.1-5build1 amd64 [installed]
adduser/focal,focal,now 3.118ubuntu2 all [installed,automatic]
adwaita-icon-theme/focal-updates,focal-updates,now 3.36.1-2ubuntu0.20.04.2 all [installed,automatic]
aisleriot/focal,now 1:3.22.9-1 amd64 [installed,automatic]
alsa-base/focal,focal,now 1.0.25+dfsg-0ubuntu5 all [installed,automatic]
zenity-common/focal,focal,now 3.32.0-5 all [installed,automatic]
zenity/focal,now 3.32.0-5 amd64 [installed,automatic]
zerofree/focal,now 1.1.1-1 amd64 [installed,automatic]
zip/focal,now 3.0-11build1 amd64 [installed,automatic]
zlib1g-dev/focal-updates,focal-security,now 1:1.2.11.dfsg-2ubuntu1.3 amd64 [installed,automatic]
zlib1g/focal-updates,focal-security,now 1:1.2.11.dfsg-2ubuntu1.3 amd64 [installed,automatic]
zlib1g/focal-updates,focal-security,now 1:1.2.11.dfsg-2ubuntu1.3 i386 [installed,automatic]
zsh-common/focal-updates,focal-updates,focal-security,focal-security,now 5.8-3ubuntu1.1 all [installed,automatic]
zsh/focal-updates,focal-security,now 5.8-3ubuntu1.1 amd64 [installed]

Display the system listing of all patches installed

$ sudo apt-show-versions -a | grep -i "security"

Display the list of needed runtime libraries to run file

Use the ldd command:
$ ldd file

Find what package a file belongs to

Use the dpkg command:
$ dpkg -S /path/to/file
$ dpkg -S /bin/ls

Create a backup list of all installed software

$ sudo dpkg --get-selections > /root/installed.pkgs.txt
Want to restore it again?
$ sudo dpkg --set-selections < /root/installed.pkgs.txt

Display the system firewall configuration

Try the iptables command and ufw command:
$ sudo iptables -L -n -v
$ sudo ufw status numbered
$ sudo ufw status verbose
$ sudo ufw app list

Summing up

That is all for now. Do not forget to read man pages featured in this post using the help command or man command as follows:
$ man dpkg
$ man htop
$ apt --help

Finally, make a backup - it cannot be stressed enough how important it is to make a backup of your system. A good backup plan allow you to recover from disk failure, accidental file deletion, file corruption, or complete server destruction, including destruction of on-site backups.

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

8 comments… add one
  • Luis Humberto Balam Gonzalez Sep 1, 2015 @ 17:43

    Good list of the tips/tricks. useful commands.

  • Ramiro Varandas Jr Sep 2, 2015 @ 0:54

    Awesome list! Nice work!

  • SK Sep 2, 2015 @ 6:32

    Thank you to putting all the useful tricks together. There is typo. It’s FQDN, not FAQN. Thanks again.

  • Ramazan Özbilen Jan 6, 2016 @ 15:18

    Nice work as always my friend!

  • userK Jan 7, 2016 @ 17:25

    I love this collection of commands! Thanks for the article!
    If you want to find out your public ip try also


  • hubertpc Aug 29, 2016 @ 20:52

    I love this list too (y). Thanks

  • Marti van Lin Aug 30, 2016 @ 6:21

    Another interesting tool is lshw, which gives detailed information about your hardware setup.

    It must be run as root, to get the best result.


    sudo lshw -html > thiscomputer.html

    Writes the output to a html file.

    See man lshw for detailed in structions and options.

  • preetham16 Apr 10, 2021 @ 8:25

    thanks you

Leave a Reply

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

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.