Never Ending Security

It starts all here

Tag Archives: lsblk

16 commands to check hardware information on Linux


Hardware information

Like for every thing, there are plenty of commands to check information about the hardware of your linux system. Some commands report only specific hardware components like cpu or memory while the rest cover multiple hardware units.

This post takes a quick look at some of the most commonly used commands to check information and configuration details about various hardware peripherals and devices. The list includes lscpu, hwinfo, lshw, dmidecode, lspci etc.

1. lscpu

The lscpu command reports information about the cpu and processing units. It does not have any further options or functionality.

$ 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:    1
Core(s) per socket:    4
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 23
Stepping:              10
CPU MHz:               1998.000
BogoMIPS:              5302.48
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              2048K
NUMA node0 CPU(s):     0-3

2. lshw – List Hardware

A general purpose utility, that reports detailed and brief information about multiple different hardware units such as cpu, memory, disk, usb controllers, network adapters etc. Lshw extracts the information from different /proc files.

$ sudo lshw -short

H/W path        Device      Class       Description
===================================================
                            system      ()
/0                          bus         DG35EC
/0/0                        processor   Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz
/0/0/1                      memory      2MiB L2 cache
/0/0/3                      memory      32KiB L1 cache
/0/2                        memory      32KiB L1 cache
/0/4                        memory      64KiB BIOS
/0/14                       memory      8GiB System Memory
/0/14/0                     memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
/0/14/1                     memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
/0/14/2                     memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
/0/14/3                     memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
/0/100                      bridge      82G35 Express DRAM Controller
/0/100/2                    display     82G35 Express Integrated Graphics Controller
/0/100/2.1                  display     82G35 Express Integrated Graphics Controller
/0/100/19       eth0        network     82566DC Gigabit Network Connection
/0/100/1a                   bus         82801H (ICH8 Family) USB UHCI Controller #4
/0/100/1a.1                 bus         82801H (ICH8 Family) USB UHCI Controller #5
/0/100/1a.7                 bus         82801H (ICH8 Family) USB2 EHCI Controller #2
/0/100/1b                   multimedia  82801H (ICH8 Family) HD Audio Controller
/0/100/1c                   bridge      82801H (ICH8 Family) PCI Express Port 1
/0/100/1c.1                 bridge      82801H (ICH8 Family) PCI Express Port 2
/0/100/1c.2                 bridge      82801H (ICH8 Family) PCI Express Port 3
/0/100/1c.2/0               storage     JMB368 IDE controller
/0/100/1d                   bus         82801H (ICH8 Family) USB UHCI Controller #1
/0/100/1d.1                 bus         82801H (ICH8 Family) USB UHCI Controller #2
/0/100/1d.2                 bus         82801H (ICH8 Family) USB UHCI Controller #3
/0/100/1d.7                 bus         82801H (ICH8 Family) USB2 EHCI Controller #1
/0/100/1e                   bridge      82801 PCI Bridge
/0/100/1e/5                 bus         FW322/323 [TrueFire] 1394a Controller
/0/100/1f                   bridge      82801HB/HR (ICH8/R) LPC Interface Controller
/0/100/1f.2                 storage     82801H (ICH8 Family) 4 port SATA Controller [IDE mode]
/0/100/1f.3                 bus         82801H (ICH8 Family) SMBus Controller
/0/100/1f.5                 storage     82801HR/HO/HH (ICH8R/DO/DH) 2 port SATA Controller [IDE m
/0/1            scsi3       storage     
/0/1/0.0.0      /dev/sda    disk        500GB ST3500418AS
/0/1/0.0.0/1    /dev/sda1   volume      70GiB Windows NTFS volume
/0/1/0.0.0/2    /dev/sda2   volume      395GiB Extended partition
/0/1/0.0.0/2/5  /dev/sda5   volume      97GiB HPFS/NTFS partition
/0/1/0.0.0/2/6  /dev/sda6   volume      97GiB Linux filesystem partition
/0/1/0.0.0/2/7  /dev/sda7   volume      1952MiB Linux swap / Solaris partition
/0/1/0.0.0/2/8  /dev/sda8   volume      198GiB Linux filesystem partition
/0/3            scsi4       storage     
/0/3/0.0.0      /dev/cdrom  disk        DVD RW DRU-190A

3. hwinfo – Hardware Information

Hwinfo is another general purpose hardware probing utility that can report detailed and brief information about multiple different hardware components, and more than what lshw can report.

$ hwinfo --short
cpu:                                                            
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2000 MHz
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2000 MHz
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2666 MHz
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2666 MHz
keyboard:
  /dev/input/event2    AT Translated Set 2 keyboard
mouse:
  /dev/input/mice      Microsoft Basic Optical Mouse v2.0
graphics card:
                       Intel 965G-1
                       Intel 82G35 Express Integrated Graphics Controller
sound:
                       Intel 82801H (ICH8 Family) HD Audio Controller
storage:
                       Intel 82801H (ICH8 Family) 4 port SATA IDE Controller
                       Intel 82801H (ICH8 Family) 2 port SATA IDE Controller
                       JMicron JMB368 IDE controller
network:
  eth0                 Intel 82566DC Gigabit Network Connection
network interface:
  eth0                 Ethernet network interface
  lo                   Loopback network interface
disk:
  /dev/sda             ST3500418AS
partition:
  /dev/sda1            Partition
  /dev/sda2            Partition
  /dev/sda5            Partition
  /dev/sda6            Partition
  /dev/sda7            Partition
  /dev/sda8            Partition
cdrom:
  /dev/sr0             SONY DVD RW DRU-190A
usb controller:
                       Intel 82801H (ICH8 Family) USB UHCI Controller #4
                       Intel 82801H (ICH8 Family) USB UHCI Controller #5
                       Intel 82801H (ICH8 Family) USB2 EHCI Controller #2
                       Intel 82801H (ICH8 Family) USB UHCI Controller #1
                       Intel 82801H (ICH8 Family) USB UHCI Controller #2
                       Intel 82801H (ICH8 Family) USB UHCI Controller #3
                       Intel 82801H (ICH8 Family) USB2 EHCI Controller #1
bios:
                       BIOS

... TRUNCATED ...

4. lspci – List PCI

The lspci command lists out all the pci buses and details about the devices connected to them.
The vga adapter, graphics card, network adapter, usb ports, sata controllers, etc all fall under this category.

$ lspci
00:00.0 Host bridge: Intel Corporation 82G35 Express DRAM Controller (rev 03)
00:02.0 VGA compatible controller: Intel Corporation 82G35 Express Integrated Graphics Controller (rev 03)
00:02.1 Display controller: Intel Corporation 82G35 Express Integrated Graphics Controller (rev 03)
00:19.0 Ethernet controller: Intel Corporation 82566DC Gigabit Network Connection (rev 02)
00:1a.0 USB controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #4 (rev 02)
00:1a.1 USB controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #5 (rev 02)
00:1a.7 USB controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #2 (rev 02)
00:1b.0 Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 02)
00:1c.0 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 1 (rev 02)
00:1c.1 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 2 (rev 02)
00:1c.2 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 3 (rev 02)
00:1d.0 USB controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #1 (rev 02)
00:1d.1 USB controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2 (rev 02)
00:1d.2 USB controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #3 (rev 02)
00:1d.7 USB controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #1 (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev f2)
00:1f.0 ISA bridge: Intel Corporation 82801HB/HR (ICH8/R) LPC Interface Controller (rev 02)
00:1f.2 IDE interface: Intel Corporation 82801H (ICH8 Family) 4 port SATA Controller [IDE mode] (rev 02)
00:1f.3 SMBus: Intel Corporation 82801H (ICH8 Family) SMBus Controller (rev 02)
00:1f.5 IDE interface: Intel Corporation 82801HR/HO/HH (ICH8R/DO/DH) 2 port SATA Controller [IDE mode] (rev 02)
03:00.0 IDE interface: JMicron Technology Corp. JMB368 IDE controller
04:05.0 FireWire (IEEE 1394): LSI Corporation FW322/323 [TrueFire] 1394a Controller (rev 70)

Filter out specific device information with grep.

$ lspci -v | grep "VGA" -A 12

5. lsscsi – List scsi devices

Lists out the scsi/sata devices like hard drives and optical drives.

$ lsscsi
[3:0:0:0]    disk    ATA      ST3500418AS      CC38  /dev/sda 
[4:0:0:0]    cd/dvd  SONY     DVD RW DRU-190A  1.63  /dev/sr0

6. lsusb – List usb buses and device details

This command shows the USB controllers and details about devices connected to them. By default brief information is printed. Use the verbose option “-v” to print detailed information about each usb port

$ lsusb
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 002: ID 045e:00cb Microsoft Corp. Basic Optical Mouse v2.0
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

On the above system, 1 usb port is being used by the mouse.

7. Inxi

Inxi is a 10K line mega bash script that fetches hardware details from multiple different sources and commands on the system, and generates a beautiful looking report that non technical users can read easily.

$ inxi -Fx

inxi linux hardware information tool

8. lsblk – List block devices

List out information all block devices, which are the hard drive partitions and other storage devices like optical drives and flash drives

$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk 
├─sda1   8:1    0    70G  0 part 
├─sda2   8:2    0     1K  0 part 
├─sda5   8:5    0  97.7G  0 part /media/4668484A68483B47
├─sda6   8:6    0  97.7G  0 part /
├─sda7   8:7    0   1.9G  0 part [SWAP]
└─sda8   8:8    0 198.5G  0 part /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1
sr0     11:0    1  1024M  0 rom

9. df – disk space of file systems

Reports various partitions, their mount points and the used and available space on each.

$ df -H
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda6       104G   26G   73G  26% /
none            4.1k     0  4.1k   0% /sys/fs/cgroup
udev            4.2G  4.1k  4.2G   1% /dev
tmpfs           837M  1.6M  835M   1% /run
none            5.3M     0  5.3M   0% /run/lock
none            4.2G   13M  4.2G   1% /run/shm
none            105M   21k  105M   1% /run/user
/dev/sda8       210G  149G   51G  75% /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1
/dev/sda5       105G   31G   75G  30% /media/4668484A68483B47

10. Pydf – Python df

An improved df version written in python, that displays colored output that looks better than df

$ pydf
Filesystem Size Used Avail Use%          Mounted on                                 
/dev/sda6   96G  23G   68G 24.4 [#.....] /                                          
/dev/sda8  195G 138G   47G 70.6 [####..] /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1
/dev/sda5   98G  28G   69G 29.2 [##....] /media/4668484A68483B47

11. fdisk

Fdisk is a utility to modify partitions on hard drives, and can be used to list out the partition information as well.

$ sudo fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x30093008

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63   146801969    73400953+   7  HPFS/NTFS/exFAT
/dev/sda2       146802031   976771071   414984520+   f  W95 Ext'd (LBA)
/dev/sda5       146802033   351614654   102406311    7  HPFS/NTFS/exFAT
/dev/sda6       351614718   556427339   102406311   83  Linux
/dev/sda7       556429312   560427007     1998848   82  Linux swap / Solaris
/dev/sda8       560429056   976771071   208171008   83  Linux

12. mount

The mount is used to mount/unmount and view mounted file systems.

$ mount | column -t
/dev/sda6    on  /                                            type  ext4             (rw,errors=remount-ro)
proc         on  /proc                                        type  proc             (rw,noexec,nosuid,nodev)
sysfs        on  /sys                                         type  sysfs            (rw,noexec,nosuid,nodev)
none         on  /sys/fs/cgroup                               type  tmpfs            (rw)
none         on  /sys/fs/fuse/connections                     type  fusectl          (rw)
none         on  /sys/kernel/debug                            type  debugfs          (rw)
none         on  /sys/kernel/security                         type  securityfs       (rw)
udev         on  /dev                                         type  devtmpfs         (rw,mode=0755)
devpts       on  /dev/pts                                     type  devpts           (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs        on  /run                                         type  tmpfs            (rw,noexec,nosuid,size=10%,mode=0755)
none         on  /run/lock                                    type  tmpfs            (rw,noexec,nosuid,nodev,size=5242880)
none         on  /run/shm                                     type  tmpfs            (rw,nosuid,nodev)
none         on  /run/user                                    type  tmpfs            (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
none         on  /sys/fs/pstore                               type  pstore           (rw)
/dev/sda8    on  /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1  type  ext4             (rw,nosuid,nodev,errors=remount-ro)
/dev/sda5    on  /media/4668484A68483B47                      type  fuseblk          (rw,nosuid,nodev,allow_other,blksize=4096)
binfmt_misc  on  /proc/sys/fs/binfmt_misc                     type  binfmt_misc      (rw,noexec,nosuid,nodev)
systemd      on  /sys/fs/cgroup/systemd                       type  cgroup           (rw,noexec,nosuid,nodev,none,name=systemd)
gvfsd-fuse   on  /run/user/1000/gvfs                          type  fuse.gvfsd-fuse  (rw,nosuid,nodev,user=enlightened)

Again, use grep to filter out only those file systems that you want to see

$ mount | column -t | grep ext

13. free – Check RAM

Check the amount of used, free and total amount of RAM on system with the free command.

$ free -m
             total       used       free     shared    buffers     cached
Mem:          7975       5865       2110          0         24        622
-/+ buffers/cache:       5218       2757
Swap:         1951        921       1030

14. dmidecode

The dmidecode command is different from all other commands. It extracts hardware information by reading data from the SMBOIS data structures (also called DMI tables).

# display information about the processor/cpu
$ sudo dmidecode -t processor

# memory/ram information
$ sudo dmidecode -t memory

# bios details
$ sudo dmidecode -t bios

Check out the man page for more details.

15. /proc files

Many of the virtual files in the /proc directory contain information about hardware and configurations. Here are some of them

CPU/Memory information

# cpu information
$ cat /proc/cpuinfo

# memory information
$ cat /proc/meminfo

Linux/kernel information

$ cat /proc/version
Linux version 3.11.0-12-generic (buildd@allspice) (gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu7) ) #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013

SCSI/Sata devices

$ cat /proc/scsi/scsi 
Attached devices:
Host: scsi3 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: ST3500418AS      Rev: CC38
  Type:   Direct-Access                    ANSI  SCSI revision: 05
Host: scsi4 Channel: 00 Id: 00 Lun: 00
  Vendor: SONY     Model: DVD RW DRU-190A  Rev: 1.63
  Type:   CD-ROM                           ANSI  SCSI revision: 05

Partitions

$ cat /proc/partitions 
major minor  #blocks  name

   8        0  488386584 sda
   8        1   73400953 sda1
   8        2          1 sda2
   8        5  102406311 sda5
   8        6  102406311 sda6
   8        7    1998848 sda7
   8        8  208171008 sda8
  11        0    1048575 sr0

16. hdparm

The hdparm command gets information about sata devices like hard disks.

$ sudo hdparm -i /dev/sda

/dev/sda:

 Model=ST3500418AS, FwRev=CC38, SerialNo=9VMJXV1N
 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
 BuffType=unknown, BuffSize=16384kB, 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:  mdma0 mdma1 mdma2 
 UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
 AdvancedPM=no WriteCache=enabled
 Drive conforms to: unknown:  ATA/ATAPI-4,5,6,7

 * signifies the current active mode

Summary

Each of the command has a slightly different method of extracting information, and you may need to try more than one of them, while looking for specific hardware details. However they are available across most linux distros, and can be easily installed from the default repositories.

On the desktop there are gui tools, for those who do not want to memorise and type commands. Hardinfo, I-nex are some of the popular ones that provide detailed information about multiple different hardware components.


Get hardware information on Linux with lshw command


Lshw – List hardware

Lshw is a nifty small command line utility that generates detailed reports about various hardware components on the system. It does so by reading different files in the /proc directory.

Lshw is capable of reporting memory configuration, firmware version, mainboard configuration, CPU version and speed, cache configuration, bus speed etc.

Install lshw

Ubuntu, Debian and Fedora users can get it from default repositories. On CentOS lshw can be installed from Epel repo.

# ubuntu, debian
$ sudo apt-get install lshw

# fedora, centos (epel)
$ sudo yum install lshw

Using lshw

The lshw command needs to run with super privileges to be able to detect and report the maximum amount of information. So run as root, or use sudo.

Lshw assorts hardware components into groups called “class”. Processor, memory, display, network, storage are all different classes.

1. Display full information

Running lshw without any options would generate full information report about all detected hardware. It would generate a big output with quite a lot of technical details

$ sudo lshw
enlightened               
    description: Desktop Computer
    product: ()
    width: 64 bits
    capabilities: smbios-2.4 dmi-2.4 vsyscall32
    configuration: boot=normal chassis=desktop uuid=949AC704-8C43-11DE-9395-000EA68F7260
  *-core
       description: Motherboard
       product: DG35EC
       vendor: Intel Corporation
       physical id: 0
       version: AAE29266-210
       serial: BTEC934000EK
       slot: Base Board Chassis Location
     *-cpu
          description: CPU
          product: Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz
          vendor: Intel Corp.
          physical id: 0
          bus info: cpu@0
          version: Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz
          slot: LGA 775
          size: 2664MHz
          capacity: 4GHz
          width: 64 bits
          clock: 333MHz
          capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx x86-64 constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority cpufreq

...TRIMMED

2. Display information in short

With the “-short” the lshw command would generate a brief information report about the hardware devices that would quickly give an idea about the hardware profile of the system.

$ sudo lshw -short
H/W path        Device      Class       Description
===================================================
                            system      ()
/0                          bus         DG35EC
/0/0                        processor   Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz
/0/0/1                      memory      2MiB L2 cache
/0/0/3                      memory      32KiB L1 cache
/0/2                        memory      32KiB L1 cache
/0/4                        memory      64KiB BIOS
/0/14                       memory      8GiB System Memory
/0/14/0                     memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
/0/14/1                     memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
/0/14/2                     memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
/0/14/3                     memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
/0/100                      bridge      82G35 Express DRAM Controller
/0/100/2                    display     82G35 Express Integrated Graphics Controller
/0/100/2.1                  display     82G35 Express Integrated Graphics Controller
/0/100/19       eth0        network     82566DC Gigabit Network Connection
/0/100/1a                   bus         82801H (ICH8 Family) USB UHCI Controller #4
/0/100/1a.1                 bus         82801H (ICH8 Family) USB UHCI Controller #5
/0/100/1a.7                 bus         82801H (ICH8 Family) USB2 EHCI Controller #2
/0/100/1b                   multimedia  82801H (ICH8 Family) HD Audio Controller
/0/100/1c                   bridge      82801H (ICH8 Family) PCI Express Port 1
/0/100/1c.1                 bridge      82801H (ICH8 Family) PCI Express Port 2
/0/100/1c.2                 bridge      82801H (ICH8 Family) PCI Express Port 3
/0/100/1c.2/0               storage     JMB368 IDE controller
/0/100/1d                   bus         82801H (ICH8 Family) USB UHCI Controller #1
/0/100/1d.1                 bus         82801H (ICH8 Family) USB UHCI Controller #2
/0/100/1d.2                 bus         82801H (ICH8 Family) USB UHCI Controller #3
/0/100/1d.7                 bus         82801H (ICH8 Family) USB2 EHCI Controller #1
/0/100/1e                   bridge      82801 PCI Bridge
/0/100/1e/5                 bus         FW322/323 [TrueFire] 1394a Controller
/0/100/1f                   bridge      82801HB/HR (ICH8/R) LPC Interface Controller
/0/100/1f.2                 storage     82801H (ICH8 Family) 4 port SATA Controller [IDE mode]
/0/100/1f.3                 bus         82801H (ICH8 Family) SMBus Controller
/0/100/1f.5                 storage     82801HR/HO/HH (ICH8R/DO/DH) 2 port SATA Controller [IDE m
/0/1            scsi3       storage     
/0/1/0.0.0      /dev/sda    disk        500GB ST3500418AS
/0/1/0.0.0/1    /dev/sda1   volume      70GiB Windows NTFS volume
/0/1/0.0.0/2    /dev/sda2   volume      395GiB Extended partition
/0/1/0.0.0/2/5  /dev/sda5   volume      97GiB HPFS/NTFS partition
/0/1/0.0.0/2/6  /dev/sda6   volume      97GiB Linux filesystem partition
/0/1/0.0.0/2/7  /dev/sda7   volume      1952MiB Linux swap / Solaris partition
/0/1/0.0.0/2/8  /dev/sda8   volume      198GiB Linux filesystem partition
/0/3            scsi4       storage     
/0/3/0.0.0      /dev/cdrom  disk        DVD RW DRU-190A

The above output is easy to interpret. The system has an intel processor, 4 RAM slots, 1 500gb hard drive with 6 partitions, 1 dvd writer, 1 network adapter, couple of usb ports etc.

The 3rd column is the class name. Lshw can display information only about a particular class if requested with the “-class” options.

3. Display only memory information

To display information about the memory, specify the memory class

$ sudo lshw -short -class memory
H/W path        Device      Class       Description
===================================================
/0/0/1                      memory      2MiB L2 cache
/0/0/3                      memory      32KiB L1 cache
/0/2                        memory      32KiB L1 cache
/0/4                        memory      64KiB BIOS
/0/14                       memory      8GiB System Memory
/0/14/0                     memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
/0/14/1                     memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
/0/14/2                     memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
/0/14/3                     memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)

4. Display processor information

With class processor, lshw would display information about the cpu. It is better to not use the short option and get full details about the processor.

$ sudo lshw -class processor
  *-cpu                   
       description: CPU
       product: Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz
       vendor: Intel Corp.
       physical id: 0
       bus info: cpu@0
       version: Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz
       slot: LGA 775
       size: 2664MHz
       capacity: 4GHz
       width: 64 bits
       clock: 333MHz
       capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx x86-64 constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority cpufreq

It should be noted that lshw does not accurately tell about the number of cores or processing units available. The above system for example is a quadcore processor with 4 processing units. Another command called lscpu gives more accurate information about the cpu.

5. Disk drives

Display the disk drives with the disk class.

$ sudo lshw -short -class disk
[sudo] password for enlightened: 
H/W path        Device      Class       Description
===================================================
/0/1/0.0.0      /dev/sda    disk        500GB ST3500418AS
/0/3/0.0.0      /dev/cdrom  disk        DVD RW DRU-190A

To display information about the partitions and controllers also, specify the storage and volume class along with the disk class. Then it would give a more clear picture about the storage on the system.

$ sudo lshw -short -class disk -class storage -class volume
H/W path        Device      Class       Description
===================================================
/0/100/1c.2/0               storage     JMB368 IDE controller
/0/100/1f.2                 storage     82801H (ICH8 Family) 4 port SATA Controller [IDE mode]
/0/100/1f.5                 storage     82801HR/HO/HH (ICH8R/DO/DH) 2 port SATA Controller [IDE m
/0/1            scsi3       storage     
/0/1/0.0.0      /dev/sda    disk        500GB ST3500418AS
/0/1/0.0.0/1    /dev/sda1   volume      70GiB Windows NTFS volume
/0/1/0.0.0/2    /dev/sda2   volume      395GiB Extended partition
/0/1/0.0.0/2/5  /dev/sda5   volume      97GiB HPFS/NTFS partition
/0/1/0.0.0/2/6  /dev/sda6   volume      97GiB Linux filesystem partition
/0/1/0.0.0/2/7  /dev/sda7   volume      1952MiB Linux swap / Solaris partition
/0/1/0.0.0/2/8  /dev/sda8   volume      198GiB Linux filesystem partition
/0/3            scsi4       storage     
/0/3/0.0.0      /dev/cdrom  disk        DVD RW DRU-190A

6. Network adapter information

Use the network class to display information about the network adapter/interface. Omitting the short option is a good idea to get detailed information about it.

$ sudo lshw -class network
  *-network               
       description: Ethernet interface
       product: 82566DC Gigabit Network Connection
       vendor: Intel Corporation
       physical id: 19
       bus info: pci@0000:00:19.0
       logical name: eth0
       version: 02
       serial: 00:1c:c0:f8:79:ee
       size: 100Mbit/s
       capacity: 1Gbit/s
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=2.3.2-k duplex=full firmware=1.1-0 ip=192.168.1.2 latency=0 link=yes multicast=yes port=twisted pair speed=100Mbit/s
       resources: irq:43 memory:e0300000-e031ffff memory:e0324000-e0324fff ioport:20c0(size=32)

The value of the “serial” field is same as the MAC address. The configuration field indicates that autonegotiation is turned on and the current operating speed is 100Mbit/s. These configurations can be modified with the ethtool command.

7. Display address details with businfo

With the businfo option lshw would output the address details of pci, usb, scsi and ide devices

$ sudo lshw -businfo
Bus info          Device      Class       Description
=====================================================
                              system      ()
                              bus         DG35EC
cpu@0                         processor   Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz
                              memory      2MiB L2 cache
                              memory      32KiB L1 cache
                              memory      32KiB L1 cache
                              memory      64KiB BIOS
                              memory      8GiB System Memory
                              memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
                              memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
                              memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
                              memory      2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
pci@0000:00:00.0              bridge      82G35 Express DRAM Controller
pci@0000:00:02.0              display     82G35 Express Integrated Graphics Controller
pci@0000:00:02.1              display     82G35 Express Integrated Graphics Controller
pci@0000:00:19.0  eth0        network     82566DC Gigabit Network Connection
pci@0000:00:1a.0              bus         82801H (ICH8 Family) USB UHCI Controller #4
pci@0000:00:1a.1              bus         82801H (ICH8 Family) USB UHCI Controller #5
pci@0000:00:1a.7              bus         82801H (ICH8 Family) USB2 EHCI Controller #2
pci@0000:00:1b.0              multimedia  82801H (ICH8 Family) HD Audio Controller
pci@0000:00:1c.0              bridge      82801H (ICH8 Family) PCI Express Port 1
pci@0000:00:1c.1              bridge      82801H (ICH8 Family) PCI Express Port 2
pci@0000:00:1c.2              bridge      82801H (ICH8 Family) PCI Express Port 3
pci@0000:03:00.0              storage     JMB368 IDE controller
pci@0000:00:1d.0              bus         82801H (ICH8 Family) USB UHCI Controller #1
pci@0000:00:1d.1              bus         82801H (ICH8 Family) USB UHCI Controller #2
pci@0000:00:1d.2              bus         82801H (ICH8 Family) USB UHCI Controller #3
pci@0000:00:1d.7              bus         82801H (ICH8 Family) USB2 EHCI Controller #1
pci@0000:00:1e.0              bridge      82801 PCI Bridge
pci@0000:04:05.0              bus         FW322/323 [TrueFire] 1394a Controller
pci@0000:00:1f.0              bridge      82801HB/HR (ICH8/R) LPC Interface Controller
pci@0000:00:1f.2              storage     82801H (ICH8 Family) 4 port SATA Controller [IDE mode]
pci@0000:00:1f.3              bus         82801H (ICH8 Family) SMBus Controller
pci@0000:00:1f.5              storage     82801HR/HO/HH (ICH8R/DO/DH) 2 port SATA Controller [IDE
                  scsi3       storage     
scsi@3:0.0.0      /dev/sda    disk        500GB ST3500418AS
scsi@3:0.0.0,1    /dev/sda1   volume      70GiB Windows NTFS volume
scsi@3:0.0.0,2    /dev/sda2   volume      395GiB Extended partition
                  /dev/sda5   volume      97GiB HPFS/NTFS partition
                  /dev/sda6   volume      97GiB Linux filesystem partition
                  /dev/sda7   volume      1952MiB Linux swap / Solaris partition
                  /dev/sda8   volume      198GiB Linux filesystem partition
                  scsi4       storage     
scsi@4:0.0.0      /dev/cdrom  disk        DVD RW DRU-190A

The output is similar to “short” option, with the first column replaced with Bus Info.

8. Generate report in html/xml format

Lshw is capable of producing reports in html, xml and json formats.

$ sudo lshw -html > hardware.html

For xml format

$ sudo lshw -xml > hardware.xml

Summary

The above examples covered nearly most of what lshw can do. Check out the man page for full documentation.

Lshw also comes with a gui frontend called lshw-gtk that reports the same information in a minimal graphical user interface. Here is a screenshot.

lshw gtk

There are many other gui tools for checking hardware information, like hardinfo that generate report in a more well organised manner and visually rich format.


Inxi is an amazing tool to check hardware information on Linux


Inxi

A very common thing linux users struggle with is to find what hardware has the OS detected and how well. Because unless the OS is aware of the hardware, it might not be using it at all. And there an entire ocean of commands to check hardware information.

There are quite a few gui tools like hardinfo, sysinfo etc on the desktop, but having a generic command line tool is far more useful and this is where Inxi works well. Inxi is a set of scripts that will detect a whole lot of information about the hardware, including vendor details, device driver configuration etc. And most importantly, it will print everything in a easy to read format.

Install inxi

Inxi is there in the default repos of most distros so just get it quick

# Ubuntu/Debian users
$ sudo apt-get install inxi

# CentOS/Fedora users
$ sudo yum install inxi

If inxi is not present on your distro, then install it by following the instructions here
https://code.google.com/p/inxi/wiki/Installation

Using inxi

Inxi comes with a huge list of options that will display more and more information about different hardware parts as much possible. So in this post we shall cover just some basics to get started and the rest you can explore.

1. Run Inxi

To get a one line snapshot of your hardware just run inxi like this.

$ inxi -c 5
CPU~Quad core Intel Core2 Quad CPU Q8400 (-MCP-) clocked at 1998.000 Mhz Kernel~3.11.0-12-generic x86_64 Up~1:43 Mem~4774.1/7975.7MB HDD~500.1GB(38.8% used) Procs~301 Client~Shell inxi~1.9.12
Color schemes - Inxi output is colored and if you need to change the color for better visibility just use the c option followed by a random number between 0-32.

2. Getting basic information

The b flag will present a good amount of basic information about the system.

$ inxi -c 5 -b
System:    Host: enlightened Kernel: 3.11.0-12-generic x86_64 (64 bit) Desktop: KDE 4.11.2 Distro: Ubuntu 13.10
Machine:   Mobo: Intel model: DG35EC version: AAE29266-210
           Bios: Intel version: ECG3510M.86A.0112.2009.0203.1136 date: 02/03/2009
CPU:       Quad core Intel Core2 Quad CPU Q8400 (-MCP-) clocked at 1998.00 MHz 
Graphics:  Card: Intel 82G35 Express Integrated Graphics Controller 
           X.Org: 1.14.3 drivers: intel (unloaded: fbdev,vesa) Resolution: 1360x768@60.0hz 
           GLX Renderer: Mesa DRI Intel 965G GLX Version: 2.1 Mesa 9.2.1
Network:   Card: Intel 82566DC Gigabit Network Connection driver: e1000e 
Drives:    HDD Total Size: 500.1GB (38.8% used)
Info:      Processes: 304 Uptime: 1:50 Memory: 4983.3/7975.7MB Client: Shell (bash) inxi: 1.9.12

The about output contains plenty of information, about the CPU, Graphics card, drives, and the OS installation. Very useful when installing drivers or diagnosing.

3. Print Hard drive partitions

Lets now print out the information about hard drive partitions. It will print out all the mounted partitions along with their mount points, and space usage.

$ inxi -p
Partition: ID: / size: 97G used: 22G (24%) fs: ext4 ID: /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1 size: 196G used: 132G (71%) fs: ext4 
           ID: /media/4668484A68483B47 size: 98G used: 28G (29%) fs: fuseblk ID: swap-1 size: 2.05GB used: 0.00GB (0%) fs: swap

To print out the unmounted partitions along with the mounted ones, use the o option with p

$ inxi  -p
Partition: ID: / size: 97G used: 22G (24%) fs: ext4 ID: /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1 size: 196G used: 132G (71%) fs: ext4 
           ID: /media/4668484A68483B47 size: 98G used: 28G (29%) fs: fuseblk ID: swap-1 size: 2.05GB used: 0.00GB (0%) fs: swap 
enlightened@enlightened:~$ inxi -po
Partition: ID: / size: 97G used: 22G (24%) fs: ext4 ID: /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1 size: 196G used: 132G (71%) fs: ext4 
           ID: /media/4668484A68483B47 size: 98G used: 28G (29%) fs: fuseblk ID: swap-1 size: 2.05GB used: 0.00GB (0%) fs: swap 
Unmounted: ID: /dev/sda1 size: 75.16G label: N/A uuid: 5E38BE8B38BE6227

Print the hard drive details like make, model and size with D option

$ inxi -D
Drives:    HDD Total Size: 500.1GB (38.8% used) 1: id: /dev/sda model: ST3500418AS size: 500.1GB

4. Optical drive details

Print out full list of drives, including all storage and optical drives along with their specifications.

$ inxi -d
Drives:    HDD Total Size: 500.1GB (38.8% used) 1: id: /dev/sda model: ST3500418AS size: 500.1GB 
           Optical: /dev/sr0 model: N/A dev-links: cdrom
           Features: speed: 12x multisession: yes audio: yes dvd: yes rw: cd-r,cd-rw,dvd-r,dvd-ram

That was quick.

5. Network interfaces and configurations

The n option simply prints out the details about the network interface along with the configuration details

$ inxi -n
Network:   Card: Intel 82566DC Gigabit Network Connection driver: e1000e 
           IF: eth0 state: up speed: 100 Mbps duplex: full mac: 00:1c:c0:f8:79:ee

Use the i optio along with n to get ip address details (both wan and lan)

$ inxi -ni
Network:   Card: Intel 82566DC Gigabit Network Connection driver: e1000e 
           IF: eth0 state: up speed: 100 Mbps duplex: full mac: 00:1c:c0:f8:79:ee
           WAN IP: 122.163.33.2 IF: eth0 ip: 192.168.1.2

6. Show Audio/sound card and graphics card information

The A option is for audio information and G is for graphics card information

$ inxi -AG
Graphics:  Card: Intel 82G35 Express Integrated Graphics Controller 
           X.Org: 1.14.3 drivers: intel (unloaded: fbdev,vesa) Resolution: 1360x768@60.0hz 
           GLX Renderer: Mesa DRI Intel 965G GLX Version: 2.1 Mesa 9.2.1
Audio:     Card: Intel 82801H (ICH8 Family) HD Audio Controller driver: snd_hda_intel Sound: ALSA ver: k3.11.0-12-generic

The graphics card details are already included with the b option.

7. Show distro specific repository data

$ inxi -r
Repos:     Active apt sources in file: /etc/apt/sources.list
           deb http://in.archive.ubuntu.com/ubuntu/ saucy main restricted
           deb-src http://in.archive.ubuntu.com/ubuntu/ saucy main restricted
           deb http://in.archive.ubuntu.com/ubuntu/ saucy-updates main restricted
           deb-src http://in.archive.ubuntu.com/ubuntu/ saucy-updates main restricted
           deb http://in.archive.ubuntu.com/ubuntu/ saucy universe
           deb-src http://in.archive.ubuntu.com/ubuntu/ saucy universe
           deb http://in.archive.ubuntu.com/ubuntu/ saucy-updates universe
           deb-src http://in.archive.ubuntu.com/ubuntu/ saucy-updates universe
           deb http://in.archive.ubuntu.com/ubuntu/ saucy multiverse
           deb-src http://in.archive.ubuntu.com/ubuntu/ saucy multiverse
           deb http://in.archive.ubuntu.com/ubuntu/ saucy-updates multiverse
           deb-src http://in.archive.ubuntu.com/ubuntu/ saucy-updates multiverse
           deb http://in.archive.ubuntu.com/ubuntu/ saucy-backports main restricted universe multiverse
           deb-src http://in.archive.ubuntu.com/ubuntu/ saucy-backports main restricted universe multiverse
           deb http://security.ubuntu.com/ubuntu saucy-security main restricted
           deb-src http://security.ubuntu.com/ubuntu saucy-security main restricted
           deb http://security.ubuntu.com/ubuntu saucy-security universe
           deb-src http://security.ubuntu.com/ubuntu saucy-security universe
           deb http://security.ubuntu.com/ubuntu saucy-security multiverse
           deb-src http://security.ubuntu.com/ubuntu saucy-security multiverse
           deb http://extras.ubuntu.com/ubuntu saucy main
           deb-src http://extras.ubuntu.com/ubuntu saucy main
           deb http://archive.canonical.com/ saucy partner
           deb http://download.virtualbox.org/virtualbox/debian saucy contrib
           Active apt sources in file: /etc/apt/sources.list.d/google-chrome.list
           deb http://dl.google.com/linux/chrome/deb/ stable main

On CentOS you would get something like this

# inxi -r
Repos:     Active yum sources in file: /etc/yum.repos.d/CentOS-Base.repo
           base ~ http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
           updates ~ http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
           extras ~ http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
           Active yum sources in file: /etc/yum.repos.d/epel.repo
           epel ~ https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
           Active yum sources in file: /etc/yum.repos.d/nginx.repo
           nginx ~ http://nginx.org/packages/centos/$releasever/$basearch/

8. Print full information

The F option give a more detailed overview of the system compared to the b (basic) option. But it does not include everything that inxi is capable of reporting.

# inxi -F
System:    Host: dhcppc3 Kernel: 2.6.32-358.11.1.el6.x86_64 x86_64 (64 bit) 
           Console: tty 0 Distro: CentOS release 6.4 (Final)
Machine:   System: innotek product: VirtualBox version: 1.2 serial: 0 
           Mobo: Oracle model: VirtualBox version: 1.2 serial: 0 Bios: innotek version: VirtualBox date: 12/01/2006
CPU:       Single core Intel Core2 Quad CPU Q8400 (-UP-) cache: 6144 KB flags: (lm nx sse sse2 sse3 ssse3) clocked at 2653.954 MHz 
Graphics:  Card: InnoTek Systemberatung VirtualBox Graphics Adapter 
           X-Vendor: N/A driver: N/A tty size: 76x26 Advanced Data: N/A for root out of X
Audio:     Card: Intel 82801AA AC'97 Audio Controller driver: Intel ICH Sound: ALSA ver: 1.0.21
Network:   Card: Intel 82540EM Gigabit Ethernet Controller driver: e1000 
           IF: eth0 state: up speed: 1000 Mbps duplex: full mac: 08:00:27:54:e4:c6
Drives:    HDD Total Size: 4.3GB (32.6% used) 1: id: /dev/sda model: VBOX_HARDDISK size: 4.3GB 
Partition: ID: / size: 2.5G used: 1.3G (53%) fs: ext4 ID: /boot size: 485M used: 52M (12%) fs: ext4 
           ID: swap-1 size: 1.04GB used: 0.00GB (0%) fs: swap 
RAID:      No RAID devices detected - /proc/mdstat and md_mod kernel raid module present
Sensors:   None detected - is lm-sensors installed and configured?
Info:      Processes: 76 Uptime: 34 min Memory: 92.1/490.6MB Runlevel: 3 Client: Shell (bash) inxi: 1.9.14

Use the i option to print the ip address information

$ inxi -Fi

9. Print eXtra data

The x option can be used with individual options to print extended or extra information about that particular hardware or profile

To print addtional information about audio system

$ inxi -A -x
Audio:     Card: Intel 82801H (ICH8 Family) HD Audio Controller driver: snd_hda_intel bus-ID: 00:1b.0 
           Sound: Advanced Linux Sound Architecture ver: k3.11.0-12-generic

To get extra information about any subset of hardware profile use the x option like above.
To get more extra information use -xx. To get even more extra information use -xxx. Inxi can’t give you anything more beyond that.

Summary

Each option prints out information about a specific hardware part. Select the ones needed or print all of it, either way its very simple and quick.

Resources

https://code.google.com/p/inxi/


Check hardware information on Linux with hwinfo command


Hwinfo

The hwinfo command is a very handy command line tool that can be used to probe for details about hardware components. It reports information about most hardware units like cpu, hdd controllers, usb controllers, network card, graphics cards, multimedia, printers etc.

Hwinfo depends on the libhd library to gather hardware information which depends on libhal.

linux hwinfo command

Hwinfo is available in the repositories of Ubuntu and Debian.

# ubuntu, debian
$ sudo apt-get install hwinfo

Using hwinfo

The help information explains how to use it

$ hwinfo --help
Usage: hwinfo [options]
Probe for hardware.
  --short        just a short listing
  --log logfile  write info to logfile
  --debug level  set debuglevel
  --version      show libhd version
  --dump-db n    dump hardware data base, 0: external, 1: internal
  --hw_item      probe for hw_item
  hw_item is one of:
   all, bios, block, bluetooth, braille, bridge, camera, cdrom, chipcard,
   cpu, disk, dsl, dvb, fingerprint, floppy, framebuffer, gfxcard, hub,
   ide, isapnp, isdn, joystick, keyboard, memory, modem, monitor, mouse,
   netcard, network, partition, pci, pcmcia, pcmcia-ctrl, pppoe, printer,
   scanner, scsi, smp, sound, storage-ctrl, sys, tape, tv, usb, usb-ctrl,
   vbe, wlan, zip

  Note: debug info is shown only in the log file. (If you specify a
  log file the debug level is implicitly set to a reasonable value.)

The options are few, just mention the hardware item for which you would like to see the information and it would display that only.

1. Display all information

Running hwinfo without any options would display detailed information about all hardware units

$ hwinfo

2. Display brief information

The “–short” option will display brief information about the hardware and not the details

$ hwinfo --short

Here is the output from my system

cpu:
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2000 MHz
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2000 MHz
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2666 MHz
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2666 MHz
keyboard:
  /dev/input/event2    AT Translated Set 2 keyboard
mouse:
  /dev/input/mice      Microsoft Basic Optical Mouse v2.0
graphics card:
                       Intel 965G-1
                       Intel 82G35 Express Integrated Graphics Controller
sound:
                       Intel 82801H (ICH8 Family) HD Audio Controller
storage:
                       Intel 82801H (ICH8 Family) 4 port SATA IDE Controller
                       Intel 82801H (ICH8 Family) 2 port SATA IDE Controller
                       JMicron JMB368 IDE controller
network:
  eth0                 Intel 82566DC Gigabit Network Connection
network interface:
  eth0                 Ethernet network interface
  lo                   Loopback network interface
disk:
  /dev/sda             ST3500418AS
partition:
  /dev/sda1            Partition
  /dev/sda2            Partition
  /dev/sda5            Partition
  /dev/sda6            Partition
  /dev/sda7            Partition
  /dev/sda8            Partition
cdrom:
  /dev/sr0             SONY DVD RW DRU-190A
usb controller:
                       Intel 82801H (ICH8 Family) USB UHCI Controller #4
                       Intel 82801H (ICH8 Family) USB UHCI Controller #5
                       Intel 82801H (ICH8 Family) USB2 EHCI Controller #2
                       Intel 82801H (ICH8 Family) USB UHCI Controller #1
                       Intel 82801H (ICH8 Family) USB UHCI Controller #2
                       Intel 82801H (ICH8 Family) USB UHCI Controller #3
                       Intel 82801H (ICH8 Family) USB2 EHCI Controller #1
bios:
                       BIOS
bridge:
                       Intel 82G35 Express DRAM Controller
                       Intel 82801H (ICH8 Family) PCI Express Port 1
                       Intel 82801H (ICH8 Family) PCI Express Port 2
                       Intel 82801H (ICH8 Family) PCI Express Port 3
                       Intel 82801 PCI Bridge
                       Intel 82801HB/HR (ICH8/R) LPC Interface Controller
hub:
                       Linux 3.11.0-12-generic uhci_hcd UHCI Host Controller
                       Linux 3.11.0-12-generic uhci_hcd UHCI Host Controller
                       Linux 3.11.0-12-generic uhci_hcd UHCI Host Controller
                       Linux 3.11.0-12-generic uhci_hcd UHCI Host Controller
                       Linux 3.11.0-12-generic uhci_hcd UHCI Host Controller
                       Linux 3.11.0-12-generic ehci_hcd EHCI Host Controller
                       Linux 3.11.0-12-generic ehci_hcd EHCI Host Controller
memory:
                       Main Memory
firewire controller:
                       Agere FW323
unknown:
                       FPU
                       DMA controller
                       PIC
                       Timer
                       Keyboard controller
                       Intel 82801H (ICH8 Family) SMBus Controller
                       Serial controller

Save it to a file

$ hwinfo --short > hardware_brief.txt

3. View CPU details

With the “–cpu” option, hwinfo would display only cpu information.

$ hwinfo --short --cpu
cpu:                                                            
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2000 MHz
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2000 MHz
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2666 MHz
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2000 MHz

Remove the short option to display detailed information, about the cpu.

4. Display network card information

$ sudo hwinfo --short --netcard
network:                                                        
  eth0                 Intel 82566DC Gigabit Network Connection

<h4>5. Storage devices and partitions</h4>

[term]
$ sudo hwinfo --short --block
disk:                                                           
  /dev/sda             ST3500418AS
partition:
  /dev/sda1            Partition
  /dev/sda2            Partition
  /dev/sda5            Partition
  /dev/sda6            Partition
  /dev/sda7            Partition
  /dev/sda8            Partition
cdrom:
  /dev/sr0             SONY DVD RW DRU-190A

6. Hard drive controllers

$ sudo hwinfo --short --storage
storage:                                                        
                       Intel 82801H (ICH8 Family) 4 port SATA IDE Controller
                       Intel 82801H (ICH8 Family) 2 port SATA IDE Controller
                       JMicron JMB368 IDE controller

7. USB devices and controllers

$ sudo hwinfo --short --usb
mouse:                                                          
  /dev/input/mice      Microsoft Basic Optical Mouse v2.0
hub:
                       Linux 3.11.0-12-generic uhci_hcd UHCI Host Controller
                       Linux 3.11.0-12-generic uhci_hcd UHCI Host Controller
                       Linux 3.11.0-12-generic uhci_hcd UHCI Host Controller
                       Linux 3.11.0-12-generic uhci_hcd UHCI Host Controller
                       Linux 3.11.0-12-generic uhci_hcd UHCI Host Controller
                       Linux 3.11.0-12-generic ehci_hcd EHCI Host Controller
                       Linux 3.11.0-12-generic ehci_hcd EHCI Host Controller

8. Display multiple devices together

To display multiple hardware units together, just add all the options

$ sudo hwinfo --short --usb --cpu --block
cpu:                                                            
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2000 MHz
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2666 MHz
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2666 MHz
                       Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz, 2000 MHz
mouse:
  /dev/input/mice      Microsoft Basic Optical Mouse v2.0
disk:
  /dev/sda             ST3500418AS
partition:
  /dev/sda1            Partition
  /dev/sda2            Partition
  /dev/sda5            Partition
  /dev/sda6            Partition
  /dev/sda7            Partition
  /dev/sda8            Partition
cdrom:
  /dev/sr0             SONY DVD RW DRU-190A
hub:
                       Linux 3.11.0-12-generic uhci_hcd UHCI Host Controller
                       Linux 3.11.0-12-generic uhci_hcd UHCI Host Controller
                       Linux 3.11.0-12-generic uhci_hcd UHCI Host Controller
                       Linux 3.11.0-12-generic uhci_hcd UHCI Host Controller
                       Linux 3.11.0-12-generic uhci_hcd UHCI Host Controller
                       Linux 3.11.0-12-generic ehci_hcd EHCI Host Controller
                       Linux 3.11.0-12-generic ehci_hcd EHCI Host Controller

9. Log information to a file

The hwinfo has an option to log all data to a file. The following command will log detailed information about all hardware units to a text file.

$ hwinfo --all --log hardware_info.txt

To log short information in addition to the detailed information, add the “short” option too. Not sure if it is supposed to work like that.

$ hwinfo --all --short --log hardware_info.txt

9 commands to check hard disk partitions and disk space on Linux


In this post we are taking a look at some commands that can be used to check up the partitions on your system. The commands would check what partitions there are on each disk and other details like the total size, used up space and file system etc.

Commands like fdisk, sfdisk and cfdisk are general partitioning tools that can not only display the partition information, but also modify them.

1. fdisk

Fdisk is the most commonly used command to check the partitions on a disk. The fdisk command can display the partitions and details like file system type. However it does not report the size of each partitions.

$ sudo fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x30093008

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63   146801969    73400953+   7  HPFS/NTFS/exFAT
/dev/sda2       146802031   976771071   414984520+   f  W95 Ext'd (LBA)
/dev/sda5       146802033   351614654   102406311    7  HPFS/NTFS/exFAT
/dev/sda6       351614718   556427339   102406311   83  Linux
/dev/sda7       556429312   560427007     1998848   82  Linux swap / Solaris
/dev/sda8       560429056   976771071   208171008   83  Linux

Disk /dev/sdb: 4048 MB, 4048551936 bytes
54 heads, 9 sectors/track, 16270 cylinders, total 7907328 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001135d

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048     7907327     3952640    b  W95 FAT32

Each device is reported separately with details about size, seconds, id and individual partitions.

2. sfdisk

Sfdisk is another utility with a purpose similar to fdisk, but with more features. It can display the size of each partition in MB.

$ sudo sfdisk -l -uM

Disk /dev/sda: 60801 cylinders, 255 heads, 63 sectors/track
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
Units = mebibytes of 1048576 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start   End    MiB    #blocks   Id  System
/dev/sda1   *     0+ 71680- 71681-  73400953+   7  HPFS/NTFS/exFAT
/dev/sda2     71680+ 476938  405259- 414984520+   f  W95 Ext'd (LBA)
/dev/sda3         0      -      0          0    0  Empty
/dev/sda4         0      -      0          0    0  Empty
/dev/sda5     71680+ 171686- 100007- 102406311    7  HPFS/NTFS/exFAT
/dev/sda6     171686+ 271693- 100007- 102406311   83  Linux
/dev/sda7     271694  273645   1952    1998848   82  Linux swap / Solaris
/dev/sda8     273647  476938  203292  208171008   83  Linux

Disk /dev/sdb: 1020 cylinders, 125 heads, 62 sectors/track
Warning: The partition table looks like it was made
  for C/H/S=*/54/9 (instead of 1020/125/62).
For this listing I'll assume that geometry.
Units = mebibytes of 1048576 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start   End    MiB    #blocks   Id  System
/dev/sdb1   *     1   3860   3860    3952640    b  W95 FAT32
                start: (c,h,s) expected (4,11,6) found (0,32,33)
                end: (c,h,s) expected (1023,53,9) found (492,53,9)
/dev/sdb2         0      -      0          0    0  Empty
/dev/sdb3         0      -      0          0    0  Empty
/dev/sdb4         0      -      0          0    0  Empty

3. cfdisk

Cfdisk is a linux partition editor with an interactive user interface based on ncurses. It can be used to list out the existing partitions as well as create or modify them.

Here is an example of how to use cfdisk to list the partitions.

linux cfdisk disk partitions

Cfdisk works with one partition at a time. So if you need to see the details of a particular disk, then pass the device name to cfdisk.

$ sudo cfdisk /dev/sdb

4. parted

Parted is yet another command line utility to list out partitions and modify them if needed.
Here is an example that lists out the partition details.

$ sudo parted -l
Model: ATA ST3500418AS (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system     Flags
 1      32.3kB  75.2GB  75.2GB  primary   ntfs            boot
 2      75.2GB  500GB   425GB   extended                  lba
 5      75.2GB  180GB   105GB   logical   ntfs
 6      180GB   285GB   105GB   logical   ext4
 7      285GB   287GB   2047MB  logical   linux-swap(v1)
 8      287GB   500GB   213GB   logical   ext4


Model: Sony Storage Media (scsi)
Disk /dev/sdb: 4049MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  4049MB  4048MB  primary  fat32        boot

5. df

Df is not a partitioning utility, but prints out details about only mounted file systems. The list generated by df even includes file systems that are not real disk partitions.

Here is a simple example

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda6        97G   43G   49G  48% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            3.9G  8.0K  3.9G   1% /dev
tmpfs           799M  1.7M  797M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            3.9G   12M  3.9G   1% /run/shm
none            100M   20K  100M   1% /run/user
/dev/sda8       196G  154G   33G  83% /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1
/dev/sda5        98G   37G   62G  38% /media/4668484A68483B47

Only the file systems that start with a /dev are actual devices or partitions.
Use grep to filter out real hard disk partitions/file systems.

$ df -h | grep ^/dev
/dev/sda6        97G   43G   49G  48% /
/dev/sda8       196G  154G   33G  83% /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1
/dev/sda5        98G   37G   62G  38% /media/4668484A68483B47

To display only real disk partitions along with partition type, use df like this

$ df -h --output=source,fstype,size,used,avail,pcent,target -x tmpfs -x devtmpfs
Filesystem     Type     Size  Used Avail Use% Mounted on
/dev/sda6      ext4      97G   43G   49G  48% /
/dev/sda8      ext4     196G  154G   33G  83% /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1
/dev/sda5      fuseblk   98G   37G   62G  38% /media/4668484A68483B47

Note that df shows only the mounted file systems or partitions and not all.

6. pydf

Improved version of df, written in python. Prints out all the hard disk partitions in a easy to read manner.

$ pydf
Filesystem Size Used Avail Use%             Mounted on                                 
/dev/sda6   96G  43G   48G 44.7 [####.....] /                                          
/dev/sda8  195G 153G   32G 78.4 [#######..] /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1
/dev/sda5   98G  36G   61G 37.1 [###......] /media/4668484A68483B47

Again, pydf is limited to showing only the mounted file systems.

7. lsblk

Lists out all the storage blocks, which includes disk partitions and optical drives. Details include the total size of the partition/block and the mount point if any.
Does not report the used/free disk space on the partitions.

$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk 
├─sda1   8:1    0    70G  0 part 
├─sda2   8:2    0     1K  0 part 
├─sda5   8:5    0  97.7G  0 part /media/4668484A68483B47
├─sda6   8:6    0  97.7G  0 part /
├─sda7   8:7    0   1.9G  0 part [SWAP]
└─sda8   8:8    0 198.5G  0 part /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1
sdb      8:16   1   3.8G  0 disk 
└─sdb1   8:17   1   3.8G  0 part 
sr0     11:0    1  1024M  0 rom

If there is no MOUNTPOINT, then it means that the file system is not yet mounted. For cd/dvd this means that there is no disk.

Lsblk is capbale of displaying more information about each device like the label and model. Check out the man page for more information

8. blkid

Prints the block device (partitions and storage media) attributes like uuid and file system type. Does not report the space on the partitions.

$ sudo blkid
/dev/sda1: UUID="5E38BE8B38BE6227" TYPE="ntfs" 
/dev/sda5: UUID="4668484A68483B47" TYPE="ntfs" 
/dev/sda6: UUID="6fa5a72a-ba26-4588-a103-74bb6b33a763" TYPE="ext4" 
/dev/sda7: UUID="94443023-34a1-4428-8f65-2fb02e571dae" TYPE="swap" 
/dev/sda8: UUID="13f35f59-f023-4d98-b06f-9dfaebefd6c1" TYPE="ext4" 
/dev/sdb1: UUID="08D1-8024" TYPE="vfat"

9. hwinfo

The hwinfo is a general purpose hardware information tool and can be used to print out the disk and partition list. The output however does not print details about each partition like the above commands.

$ hwinfo --block --short
disk:                                                           
  /dev/sda             ST3500418AS
  /dev/sdb             Sony Storage Media
partition:
  /dev/sda1            Partition
  /dev/sda2            Partition
  /dev/sda5            Partition
  /dev/sda6            Partition
  /dev/sda7            Partition
  /dev/sda8            Partition
  /dev/sdb1            Partition
cdrom:
  /dev/sr0             SONY DVD RW DRU-190A

Summary

The output of parted is concise and complete to get an overview of different partitions, file system on them and the total space. Pydf and df are limited to showing only mounted file systems and the same on them.

Fdisk and Sfdisk show a whole lot of information that can take sometime to interpret whereas, Cfdisk is an interactive partitioning tool that display a single device at a time.

So try them out, and do not forget to comment below.