Unveiling the Mysteries of Your Linux System: Exploring Hardware Information

Hey there, fellow Linux enthusiasts! πŸ‘‹

Curious to explore the hardware wonders tucked away in your machine? Well, you're in for a treat! In this blog post, we're embarking on a delightful journey to uncover the fascinating world of displaying hardware information on Linux.🐧

Whether you're a command-line veteran or a curious newcomer, we've got something special for everyone. So, buckle up your seatbelts and get ready for a ride through the heart and soul of your Linux system!

Stick around until the end of the blog post – I've saved the best for last! Discover my favorite commands and top recommendations, especially recommended for beginners.

Unveiling Linux Hardware: Dive into /proc Directory

There are numerous commands to check information about your Linux system hardware. Specific commands target components like CPU or memory, while others provide comprehensive insights into various hardware units. One crucial directory is the /proc directory, a cornerstone in Unix or GNU/Linux systems.

The directory doesn't contain "real files" but houses information about your runtime system. It functions as a control and information center for the kernel. Among the wealth of information in /proc, discover details like memory usage, mounted storage devices, current hardware configuration, system uptime, and more.

Here are some examples:

  • lsmod: Displays the contents of /proc/modules, which are the currently loaded kernel modules.
lsmod
#Output
Module                  Size  Used by
nvidia               16861184  0
vboxsf                 45056  0
vboxguest             356352  1 vboxsf
snd_hda_codec_realtek   122880  1
snd_hda_codec_generic    98304  1 snd_hda_codec_realtek
snd_hda_codec_hdmi     57344  1
snd_hda_intel          57344  3
snd_intel_dspcfg       28672  1 snd_hda_intel
snd_hda_codec         147456  4 snd_hda_codec_realtek,snd_hda_codec_hdmi,snd_hda_codec_generic,snd_hda_intel
snd_hwdep              20480  1 snd_hda_codec
snd_hda_core           94208  5 snd_hda_codec_realtek,snd_hda_codec_hdmi,snd_hda_codec_generic,snd_hda_intel,snd_hda_codec
snd_pcm               118784  4 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hda_core
snd_timer              40960  1 snd_pcm
  • lspci: Displays detailed information about PCI (Peripheral Component Interconnect) buses and devices connected to them in your system. Gathers information from /proc/bus/pci/ . VGA adapters, graphics cards, network adapters, USB controllers, SATA controllers, and many others fall into this category.
lspci
#Output
00:00.0 Host bridge: Intel Corporation 8th Gen Core Processor Host Bridge/DRAM Registers (rev 07)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16) (rev 07)
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 620 (rev 07)
...
  • uptime: Displays the content of /proc/uptime, which is the system's current time, up time, number of users, and load averages.
uptime
#Output
 10:27:03 up 5 days,  2:14,  3 users,  load average: 0.14, 0.19, 0.12
  • lshw: Reports detailed and brief information about various units of different hardware such as CPU, memory, disk, USB controllers, network adapters, etc. It extracts information from different /proc files.

    Note: The command should be run as a super-user:

sudo lshw -short
#Output
H/W path        Device       Class          Description
=======================================================
                            system         Computer
/0                          bus            Motherboard
/0/0                        memory         64KiB BIOS
/0/4                        processor      Intel Core i7-8700K
/0/4/5                      memory         32GiB System Memory
/0/4/5/0                    memory         16GiB DIMM DDR4 Synchronous
/0/4/5/1                    memory         16GiB DIMM DDR4 Synchronous
/0/100/1/0                   display        NVIDIA GeForce GTX 1080
/0/100/14                    bus            200 Series/Z370 Chipset Family USB 3.0 xHCI Controller
/0/100/14/0                  generic        USB hub
/0/100/14/1                  communication  Bluetooth wireless interface
/0/100/14.2                  multimedia     200 Series/Z370 Chipset Family HD Audio Controller
/0/100/16                    communication  200 Series PCH CSME HECI #1
...
  • lscpu: Reports information about the CPU and processing units. Located in /proc/cpuinfo
lscpu
#Output
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                8
On-line CPU(s) list:   0-7
Thread(s) per core:    2
Core(s) per socket:    4
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 158
Model name:            Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
Stepping:              10
CPU MHz:               800.000
BogoMIPS:              7392.00
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              12288K
  • lsscsi: Lists SCSI (Small Computer System Interface) and SATA (Serial ATA) devices such as hard drives and optical drives. It gathers information from /proc/scsi/scsi
lsscsi
#Output
[0:0:0:0]    disk    ATA      ST1000DM003-1SB1 CC49  /dev/sda
[1:0:0:0]    cd/dvd  HL-DT-ST DVDRAM GH24NSC0  LK00  /dev/sr0

Beyond /proc : exploring other commands

  • lsusb: Shows USB controllers and details about devices connected to them. By default, it provides a brief summary of it. Use the verbose option β€œ-v” to print detailed information about each USB port. It reads information from /sys/bus/usb/
lsusb -v
#Output
Bus 002 Device 001: ID 1d6b:0003
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               3.00
  bDeviceClass            9 Hub
  ...
  iManufacturer           3 Linux 5.4.0-89-generic xhci-hcd
  ...
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       12345
    bNumInterfaces          1
    ...
  • dmidecode: Retrieves detailed hardware information from the system's BIOS using the Desktop Management Interface (DMI). It provides a comprehensive overview of various components such as the system, BIOS, processor, memory, connectors,etc. It interacts with the /sys/class/dmi/ directory.

    Note: The command should be run as a super-user:

      sudo dmidecode -t processor
    
      #Output
      Getting SMBIOS data from sysfs.
      SMBIOS 2.7 present.
    
      Handle 0x0004, DMI type 4, 42 bytes
      Processor Information
          Socket Designation: CPU Socket
          Type: Central Processor
          Family: Intel Core i7
          Manufacturer: Intel
          ID: AB CD 01 02
          Version: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
          Voltage: 1.2 V
          External Clock: 100 MHz
          Max Speed: 4300 MHz
          Current Speed: 3700 MHz
          Status: Populated, Enabled
          Upgrade: Socket LGA1151
          L1 Cache Handle: 0x0005
          L2 Cache Handle: 0x0006
          L3 Cache Handle: 0x0007
          Serial Number: Not Specified
          Asset Tag: Not Specified
          Part Number: Not Specified
    
      sudo dmidecode -t memory
    
      #Output
      Getting SMBIOS data from sysfs.
      SMBIOS 2.7 present.
    
      Handle 0x002A, DMI type 17, 34 bytes
      Memory Device
          Array Handle: 0x0029
          Error Information Handle: Not Provided
          Total Width: 64 bits
          Data Width: 64 bits
          Size: 16384 MB
          Form Factor: DIMM
          Set: None
          Locator: ChannelA-DIMM0
          Bank Locator: BANK 0
          Type: DDR4
          Type Detail: Synchronous
          Speed: 2400 MT/s
          Manufacturer: Kingston
          Serial Number: 12345678
          Asset Tag: Not Specified
          Part Number: KHX2400C15/16G
          Rank: 2
          Configured Memory Speed: 2400 MT/s
          Minimum Voltage: 1.2 V
          Maximum Voltage: 1.2 V
          Configured Voltage: 1.2 V
    
  • hdparm: Obtains information about SATA devices such as hard drives. It communicates directly with the hardware to retrieve information about devices.

hdparm -I /dev/sda
#Output
/dev/sda:

ATA device, with non-removable media
    Model Number:       ST1000DM003-1CH162
    Serial Number:      Z1ABCD23
    Firmware Revision:  CC47
    Transport:          Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Standards:
    Supported: 9 8 7 6 5
    Likely used: 9
Configuration:
    Logical        max    current
    cylinders    16383    16383
    heads           16        16
    sectors/track    63        63
    --
    CHS current addressable sectors:    16514064
    LBA    user addressable sectors:   268435455
    LBA48  user addressable sectors:  1953525168
    Logical/Physical Sector size:           512 bytes
    device size with M = 1024*1024:      953869 MBytes
    device size with M = 1000*1000:     1000204 MBytes (1000 GB)
Capabilities:
    LBA, IORDY(can be disabled)
    Queue depth: 32
    Standby timer values: spec'd by Standard, with device specific minimum
    R/W multiple sector transfer: Max = 16  Current = 16
    Advanced power management level: 128
    Write cache: enabled
    Read look-ahead: enabled
    Write look-ahead: enabled
    Device supports TRIM command
    Device supports S.M.A.R.T. and is Enabled
  • hwinfo: Another general-purpose hardware analysis utility that can report detailed and brief information about several different hardware components, much more than that lshw can report. Like hdparm, it also includes direct hardware interactions.
hwinfo --short
#Output
cpu:                                                               
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 4192 MHz
keyboard:
  /dev/input/event3    AT Translated Set 2 keyboard
mouse:
  /dev/input/mice      HID 413c:3012
monitor:
                       Generic PnP Monitor
graphics card:
                       NVIDIA GeForce GTX 1080
sound:
                       Intel Cannon Lake PCH cAVS
storage:
                       Samsung SSD 970 EVO 500GB, ST1000DM003-1SB102
network:
  wlp0s20f3            Intel Wireless-AC 9560 [Jefferson Peak]
  enp3s0               Intel Ethernet Connection I219-V
network interface:
  lo                   Loopback network interface
  wlp0s20f3            Wireless network interface
  enp3s0               Ethernet network interface
disk:
  /dev/sda             Samsung SSD 970 EVO 500GB
  /dev/sdb             ST1000DM003-1SB102
partition:
  /dev/sda1            Partition
  /dev/sda2            Partition
  /dev/sdb1            Partition
cdrom:
  /dev/sr0             HL-DT-ST DVDRAM GH24NSC0
usb controller:
                       Intel Cannon Lake PCH USB 3.1 xHCI Host Controller
bios:
                       American Megatrends Inc. 1.2.3, 01/01/2020
  • dmesg: Used to display the message buffer of the kernel. It shows system event information, including kernel messages, device drivers, and other system components.
dmesg
#Output
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 5.4.0-88-generic (buildd@lcy01-amd64-019) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)) #99-Ubuntu SMP Thu Sep 23 17:29:00 UTC 2021 (Ubuntu 5.4.0-88.99-generic 5.4.153)
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.4.0-88-generic root=UUID=12345678-1234-1234-1234-1234567890ab ro quiet splash
[    0.000000] KERNEL supported cpus:
[    0.000000]   Intel GenuineIntel
[    0.000000]   AMD AuthenticAMD
[    0.000000]   Hygon HygonGenuine
[    0.000000]   Centaur CentaurHauls
[    0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[    0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[    0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[    0.000000] x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]:  256
[    0.000000] x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format.
...
  • lsblk: List information about block devices, such as hard drives and partitions. It provides a concise overview of the storage devices connected to the system, their mount points, sizes, and other relevant details. It interacts with the kernel's block layer and reads information from /sys and /dev.
lsblk
#Output
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 238.5G  0 disk 
β”œβ”€sda1        8:1    0   512M  0 part /boot/efi
β”œβ”€sda2        8:2    0   244M  0 part /boot
└─sda3        8:3    0 237.7G  0 part 
  └─ubuntu--vg-root
            252:0    0 236.7G  0 lvm  /

These commands present the output in a more structured and readable format.

Exploring My Favorite Hardware Info Commands

When I embarked on my journey into the Linux world, deciphering hardware specifications through the command line proved quite a challenge. Coming from a Windows background, I longed for a straightforward view of my computer's properties. The commands listed below played a pivotal role in guiding me through this learning adventure:

  1. procinfo: provides a summary of the system's current state by extracting information from the /proc filesystem. This can be valuable for understanding various aspects of your Linux system.
procinfo
#Output
Linux 5.4.0-89-generic (hostname) (tty1)

 System information:
  CPU   : Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
  Memory: 16320 MB (15887 MB free)
  Uptime: 2 days, 4 hours, 15 minutes

 Load average: 0.15 0.30 0.25 1/117 12345

 Processes:
  Running: 1
  Sleeping: 124
  Stopped: 0
  Zombie: 0

 CPU states:
  User: 6.4%
  System: 2.0%
  Nice: 0.0%
  Idle: 91.6%

 Memory usage:
  Total: 16320 MB
  Used: 2432 MB
  Free: 13888 MB

 Swap usage:
  Total: 2047 MB
  Used: 0 MB
  Free: 2047 MB

 File system information:
  /dev/sda1: 42% used (22GB/52GB)
  /dev/sdb1: 18% used (180GB/1TB)
  ...

 Network information:
  eth0: 192.168.1.2 (1000 Mbps)
  wlan0: Not connected
  1. uname: Prints basic information about the operating system's name and system hardware. It retrieves system information by querying the kernel. /proc/sys/kernel/ may be indirectly involved as it represents kernel-related parameters.

Displaying all informations:

uname -a
#Output
Linux your_hostname 5.4.0-88-generic #99-Ubuntu SMP Thu Sep 23 17:29:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
  1. inxi: It offers a convenient way for users and administrators to quickly gather essential information about their system in a single command, facilitating system analysis and troubleshooting. It collects data from various sources, including /proc, /sys, /dev, and direct hardware interactions.
inxi
#Output
System:    Host: your_hostname Kernel: 5.4.0-88-generic x86_64 bits: 64 Desktop: GNOME 3.36.9
           Distro: Ubuntu 20.04.3 LTS (Focal Fossa)
Machine:   Type: Laptop System: Manufacturer Model: Your_Laptop_Model
           Mobo: Your_Motherboard_Model UEFI [Legacy]: Your_UEFI_Version
CPU:       Topology: Quad Core model: Intel Core i7-8550U bits: 64 type: MT MCP L2 cache: 8192 KiB
           Speed: 800 MHz min/max: 400/4000 MHz Core speeds (MHz): 1: 800 2: 800 3: 800 4: 800 5: 800 6: 800 7: 800 8: 800
Graphics:  Device-1: Intel UHD Graphics 620 driver: i915 v: kernel
           Device-2: NVIDIA GeForce MX150 driver: nouveau v: kernel
           Display: x11 server: X.org 1.20.9 driver: modesetting unloaded: fbdev,vesa resolution: 1920x1080~60Hz
           OpenGL: renderer: Mesa Intel UHD Graphics 620 (KBL GT2) v: 4.6 Mesa 20.2.6
Audio:     Device-1: Intel Sunrise Point-LP HD Audio driver: snd_hda_intel
           Sound Server: ALSA v: k5.4.0-88-generic
Network:   Device-1: Intel Wireless 8265 / 8275 driver: iwlwifi
           IF: wlp2s0 state: up mac: xx:xx:xx:xx:xx:xx
           Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet driver: r8169
           IF: enp3s0 state: down mac: xx:xx:xx:xx:xx:xx
Drives:    Local Storage: total: 256.42 GiB used: 32.95 GiB (12.8%)
           ID-1: /dev/nvme0n1 vendor: Your_NVM_Model size: 238.47 GiB
           ID-2: /dev/sda type: USB model: Your_USB_Drive size: 17.95 GiB
Partition: ID-1: / size: 93.91 GiB used: 32.91 GiB (35.1%) fs: ext4 dev: /dev/nvme0n1p5
Sensors:   System Temperatures: cpu: 50.0 C mobo: N/A gpu: nouveau temp: 47 C
           Fan Speeds (RPM): N/A
Info:      Processes: 289 Uptime: 1d 2h 16m Memory: 15.51 GiB used: 3.75 GiB (24.2%) Shell: bash inxi: 3.0.38
  1. neofetch: It is a popular and lightweight tool used in Linux and other Unix-like operating systems to display system information visually appealingly. When you run the neofetch command, it gathers various details about your system and presents them in a colorful ASCII art format. Install and run the command on your machine for better visualization.

    Discover the step-by-step guide on implementing this on your local machine by visiting its GitHub repository."

neofetch
 #Output
           .-/+oossssoo+/-.               user@hostname
        `:+ssssssssssssssssss+:`           ---------------------- 
      -+ssssssssssssssssssyyssss+-         OS: Ubuntu 22.04.3 LTS x86_64 
    .ossssssssssssssssssdMMMNysssso.       Host: G3 3500 
   /ssssssssssshdmmNNmmyNMMMMhssssss/      Kernel: 6.2.0-39-generic 
  +ssssssssshmydMMMMMMMNddddyssssssss+     Uptime: 4 hours, 57 mins 
 /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/    Packages: 2314 (dpkg), 19 (snap) 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Shell: bash 5.1.16 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   Resolution: 1920x1080 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   DE: GNOME 42.9 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   WM: Mutter 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   WM Theme: Adwaita 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Theme: Yaru-magenta-dark [GTK2/3] 
 /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/    Icons: Yaru-magenta [GTK2/3] 
  +sssssssssdmydMMMMMMMMddddyssssssss+     Terminal: gnome-terminal 
   /ssssssssssshdmNNNNmyNMMMMhssssss/      CPU: Intel i7-10750H (12) @ 5.000GHz 
    .ossssssssssssssssssdMMMNysssso.       GPU: NVIDIA GeForce GTX 1660 Ti Mobi 
      -+sssssssssssssssssyyyssss+-         GPU: Intel CometLake-H GT2 [UHD Grap 
        `:+ssssssssssssssssss+:`           Memory: 5294MiB / 15744MiB 
            .-/+oossssoo+/-.
  1. free: Shows information about system memory (RAM). It retrieves information from the kernel's /proc/meminfo file.
free -h
 #Output
             total        used        free      shared  buff/cache   available
Mem:           15Gi       2.5Gi       8.4Gi       346Mi       4.3Gi        12Gi
Swap:         2.0Gi          0B       2.0Gi
  1. df: Prints information about disk space usage. It gathers information by reading the /etc/mtab file or querying the kernel's /proc/mounts file.
df -h
#Output
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        20G   8.5G   10G  46% /
tmpfs            2.0G     0  2.0G   0% /dev/shm
/dev/sdb1       200G   50G  150G  25% /mnt/data

Quick tip

Feel free to get creative with these commands – there's no need to stick to the exact usage mentioned in this post. I highly recommend diving into --help and man for some command magic. It's like unlocking a treasure trove of information to supercharge your search and make the Linux experience your own!

Conclusion

There you have it – a comprehensive guide to showcase hardware information in Linux! Armed with these user-friendly commands and tools, you're now equipped to unravel the mysteries of your machine. Whether you're a beginner or an expert, understanding your hardware is a key step towards mastering the Linux environment. Happy exploring!

Β