Language
Category
Search

Commands to get information from the machine's hardware in Linux

List of commands to display hardware configurations on the Linux machine using the terminal: cpu, memory, usb, network, video cards, HD, SSD, DVDs, sata, partitions, free space

At Terminal By Rudi Drusian Lange
Published on
Last updated

We are used to the ls command in Linux to display files within a folder, there are several commands to get hardware information, let's start with the ls_hardware_name commands which are easy to remember.

Remember to use root user or the sudo command.

lscpu

Displays processor and processing unit information.

# Shell

lscpu

Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 58
Model name:            Intel(R) Core(TM) i3-3217U CPU @ 1.80GHz
Stepping:              9
CPU MHz:               1800.000
CPU max MHz:           1800.0000
CPU min MHz:           800.0000
BogoMIPS:              3591.88
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              3072K

lspci

Displays information about all devices connected to pci buses such as VGA adapters, video cards, network adapters, usb ports, sata controllers, among others.

# Shell

lspci

00:00.0 Host bridge: Intel Corporation 3rd Gen Core processor DRAM Controller (rev 09)
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04)
00:16.0 Communication controller: Intel Corporation 7 Series/C210 Series Chipset Family MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 1 (rev c4)
00:1c.1 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 2 (rev c4)
00:1c.2 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 3 (rev c4)
00:1d.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation HM77 Express Chipset LPC Controller (rev 04)
00:1f.2 RAID bus controller: Intel Corporation 82801 Mobile SATA Controller [RAID mode] (rev 04)
00:1f.3 SMBus: Intel Corporation 7 Series/C210 Series Chipset Family SMBus Controller (rev 04)
01:00.0 Network controller: Ralink corp. RT3290 Wireless 802.11n 1T/1R PCIe
01:00.1 Bluetooth: Ralink corp. RT3290 Bluetooth
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8101/2/6E PCI Express Fast/Gigabit Ethernet controller (rev 05)
03:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS5229 PCI Express Card Reader (rev 01)

To find specific information about a device, use the grep command.

# Shell

lspci -v|grep "Network" -A10

01:00.0 Network controller: Ralink corp. RT3290 Wireless 802.11n 1T/1R PCIe
        Subsystem: Hewlett-Packard Company RT3290 Wireless 802.11n 1T/1R PCIe
        Flags: bus master, fast devsel, latency 0, IRQ 16
        Memory at 52510000 (32-bit, non-prefetchable) [size=64K]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable- Count=1/32 Maskable- 64bit+
        Capabilities: [70] Express Endpoint, MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [140] Device Serial Number 00-00-61-23-fc-31-17-a4
        Kernel driver in use: rt2800pci
        Kernel modules: rt2800pci

To show even more information, use the lspci command with the -vv option.

-A10: shows the next ten lines after finding the searched item.

lsscsi

Displays information about scsi/sata devices such as hard drives and optical drives.

# Shell

lsscsi

[0:0:0:0]    disk    ATA      TOSHIBA MQ01ABD0 1C    /dev/sda
[1:0:0:0]    disk    ATA      MZMPC032HBCD-000 2H1Q  /dev/sdb
[10:0:0:0]   cd/dvd  Linux    File-Stor Gadget 0310  /dev/sr0

lsusb

Displays information about USB controllers and devices connected to them. Use -v for more verbose.

# Shell

lsusb

Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 005: ID 17ef:7993 Lenovo
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 04f2:b35f Chicony Electronics Co., Ltd
Bus 003 Device 002: ID 046d:c534 Logitech, Inc. Unifying Receiver
Bus 003 Device 008: ID 1c4f:0032 SiGma Micro
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

lsblk

Displays partition information for storage devices.

# Shell

lsblk

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk
├─sda1   8:1    0   7.8G  0 part [SWAP]
├─sda2   8:2    0   9.8G  0 part /var
└─sda3   8:3    0 351.6G  0 part /home
sdb      8:16   0  29.8G  0 disk
└─sdb1   8:17   0  29.8G  0 part /

lshw

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.

# Shell

lshw -short

H/W path       Device  Class          Description
=================================================
                       system         HP Pavilion Sleekbook 14 PC (C1C39LA#AC4)
/0                     bus            18FA
/0/0                   memory         8GiB System Memory
/0/0/0                 memory         4GiB SODIMM DDR3 Synchronous 1600 MHz (0.6 ns)
/0/0/1                 memory         4GiB SODIMM DDR3 Synchronous 1600 MHz (0.6 ns)
/0/9                   memory         128KiB BIOS
/0/20                  processor      Intel(R) Core(TM) i3-3217U CPU @ 1.80GHz
/0/20/22               memory         32KiB L1 cache
/0/20/23               memory         256KiB L2 cache
/0/20/24               memory         3MiB L3 cache
/0/21                  memory         32KiB L1 cache
/0/100                 bridge         3rd Gen Core processor DRAM Controller
/0/100/2               display        3rd Gen Core processor Graphics Controller
/0/100/14              bus            7 Series/C210 Series Chipset Family USB xHCI Host Controller
/0/100/16              communication  7 Series/C210 Series Chipset Family MEI Controller #1
/0/100/1a              bus            7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2
/0/100/1b              multimedia     7 Series/C210 Series Chipset Family High Definition Audio Controller
/0/100/1c              bridge         7 Series/C210 Series Chipset Family PCI Express Root Port 1
/0/100/1c/0    wlan0   network        RT3290 Wireless 802.11n 1T/1R PCIe
/0/100/1c/0.1          generic        RT3290 Bluetooth
/0/100/1c.1            bridge         7 Series/C210 Series Chipset Family PCI Express Root Port 2
/0/100/1c.1/0  eth0    network        RTL8101/2/6E PCI Express Fast/Gigabit Ethernet controller
/0/100/1c.2            bridge         7 Series/C210 Series Chipset Family PCI Express Root Port 3
/0/100/1c.2/0          generic        RTS5229 PCI Express Card Reader
/0/100/1d              bus            7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1
/0/100/1f              bridge         HM77 Express Chipset LPC Controller
/0/100/1f.2            storage        82801 Mobile SATA Controller [RAID mode]
/0/100/1f.3            bus            7 Series/C210 Series Chipset Family SMBus Controller
/1                     power          VK04037
/2             scsi10  storage

Get more information about the lshw command at: Checking machine hardware information in the Linux terminal with lshw.

hwinfo

Another command used to consult information on various hardware components.

# Shell

hwinfo --short

cpu:
                       Intel(R) Core(TM) i3-3217U CPU @ 1.80GHz, 1559 MHz
                       Intel(R) Core(TM) i3-3217U CPU @ 1.80GHz, 1553 MHz
                       Intel(R) Core(TM) i3-3217U CPU @ 1.80GHz, 1715 MHz
                       Intel(R) Core(TM) i3-3217U CPU @ 1.80GHz, 1756 MHz
keyboard:
  /dev/input/event13   Logitech Unifying Receiver
  /dev/input/event1    AT Translated Set 2 keyboard
mouse:
  /dev/input/mice      SiGma Micro Usb Mouse
  /dev/input/mice      Logitech Unifying Receiver
  /dev/input/mice      SynPS/2 Synaptics TouchPad
joystick:
  /dev/input/event5    ST LIS3LV02DL Accelerometer
monitor:
                       LCD Monitor
graphics card:
                       Intel 3rd Gen Core processor Graphics Controller
sound:
                       Intel 7 Series/C216 Chipset Family High Definition Audio Controller
storage:
                       Intel 82801 Mobile SATA Controller [RAID mode]
network:
  wlan0                Ralink RT3290 Wireless 802.11n 1T/1R PCIe
  eth0                 Realtek RTL8101/2/6E PCI Express Fast/Gigabit Ethernet controller
network interface:
  lo                   Loopback network interface
  eth0                 Ethernet network interface
  wlan0                WLAN network interface
... Interrompido ...

inxi

Inxi has a more user-friendly display.

Print do comando inxi

df

Displays information about partitions, mount points, free and occupied space.

# Shell

df -H

Filesystem      Size  Used Avail Use% Mounted on
/dev/root        32G   21G  8.9G  71% /
devtmpfs        4.2G     0  4.2G   0% /dev
tmpfs           4.2G  1.1M  4.2G   1% /run
tmpfs           4.2G   17M  4.2G   1% /dev/shm
cgroup_root     4.2G     0  4.2G   0% /sys/fs/cgroup
/dev/sda2        11G  7.3G  2.4G  76% /var
/dev/sda3       372G  296G   57G  84% /home
cgmfs           103k     0  103k   0% /run/cgmanager/fs

pydf

A more user-friendly version of the df command that displays information highlighted with color.

# Shell

pydf

Filesystem  Size  Used Avail Use%                                          Mounted on
/dev/sdb1    29G   19G 8421M 66.7 [#########################.............] /
/dev/sda3   346G  275G   53G 79.6 [##############################........] /home
/dev/sda2  9715M 6929M 2270M 71.3 [###########################...........] /var 

fdisk

Well-known utility for creating and modifying partitions in Linux but which can also be used to list information.

# Shell

fdisk -l

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: D9240990-E84F-4647-A808-841B98CFD6F9

Device        Start       End   Sectors   Size Type
/dev/sda1      2048  16386047  16384000   7.8G Linux swap
/dev/sda2  16386048  36866047  20480000   9.8G Linux filesystem
/dev/sda3  36866048 774146047 737280000 351.6G Linux filesystem

mount

Another one that is not strange in the Linux world, generally used for mounting/unmounting but which also displays information about the mounted partitions.

# Shell

mount | column -t

/dev/sdb1   on  /                 type  ext4             (rw,noatime,nodiratime,discard,errors=remount-ro)
proc        on  /proc             type  proc             (rw)
sysfs       on  /sys              type  sysfs            (rw)
tmpfs       on  /dev/shm          type  tmpfs            (rw)
/dev/sda2   on  /var              type  ext4             (rw)
/dev/sda3   on  /home             type  ext4             (rw)
gvfsd-fuse  on  /home/rudi/.gvfs  type  fuse.gvfsd-fuse  (rw,nosuid,nodev,user=rudi)

free

Checks the use of RAM and swap memory. -m to display in mega bytes;

# Shell

free -m

              total        used        free      shared  buff/cache   available
Mem:           7865        2351        1613         155        3900        4904
Swap:          7999           0        7999

dmidecode

This command fetches information by reading data directly from BIOS tables.

# Shell

# Search processor information (cpu)
dmidecode -t processor

# Search memory information
dmidecode -t memory

# BIOS details
dmidecode -t bios

/proc

The /proc directory contains several files with information about different devices.

# Shell

# cpu
cat /proc/cpuinfo

# memory
cat /proc/meminfo

# Linux/Kernel
cat /proc/version

# Scsi/Sata
cat /proc/scsi/scsi

# Partitions
cat /proc/partitions

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.

# Shell

hdparm -i /dev/sda

/dev/sda:

 Model=TOSHIBA MQ01ABD050, FwRev=AX001C, SerialNo=Y2CCF6VKS
 Config={ Fixed }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=unknown, BuffSize=8192kB, MaxMultSect=16, MultSect=16
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=976773168
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio1 pio2 pio3 pio4
 DMA modes:  sdma0 sdma1 sdma2 mdma0 mdma1 mdma2
 UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5
 AdvancedPM=yes: unknown setting WriteCache=enabled
 Drive conforms to: Unspecified:  ATA/ATAPI-3,4,5,6,7

 * signifies the current active mode

Finishing

Each command extracts information in a different way and you can use more than one of them to get what you are looking for. These commands are native to many distributions or can be easily installed through the package manager.

Referência

This is not my original language and I don't speak it very well. I used my little knowledge and translators tools to compose the text of this article. Sorry for possible spelling or grammatical errors, suggestions for corrections are appreciated and can be sent to the contact email in the footer of the site. My intention is to share some knowledge and I hope this translation is good enough.