Linux Commands - Hardware commands

Reference Linux

Following are some of the important hardware commands in Linux.

cat /proc/cpuinfo

This will list the CPU information.

In the following example we are getting details about the CPU.

$ cat /proc/cpuinfo 
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 69
model name      : Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
stepping        : 1
cpu MHz         : 2600.000
cache size      : 3072 KB
...
...
...

cat /proc/meminfo

This will list the memory information.

In the following example we are getting details about the memory.

$ cat /proc/meminfo 
MemTotal:        2041316 kB
MemFree:          120736 kB
MemAvailable:     833036 kB
Buffers:           87148 kB
Cached:           727896 kB
SwapCached:           52 kB
...
...

free -h

This command displays the amount of free and used memory in the system.

In the following example we are getting the free and used memory.

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           1.9G        933M        208M         10M        851M        880M
Swap:          1.4G        780K        1.4G

df -h

This command reports the file system disk space usage.

In the following example we are getting the disk space usage.

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            969M     0  969M   0% /dev
tmpfs           200M  1.5M  198M   1% /run
/dev/sda1        30G  6.0G   22G  22% /
...
...
...

lshw

This command will list the detail of hardware.

Use sudo if you get Permission Denied response.

In the following example we are getting the hardware details.

$ lshw
yusufshakeel-ubuntu                
    description: Computer
    width: 64 bits
    capabilities: vsyscall32
  *-core
       description: Motherboard
       physical id: 0
     *-memory
          description: System memory
          physical id: 0
          size: 1993MiB
     *-cpu
          product: Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
          vendor: Intel Corp.
          physical id: 1
          bus info: cpu@0
          width: 64 bits
...
...
...

lsusb

This command will list the USB devices.

In the following example we are getting the USB device information.

$ lsusb
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

hdparm

This will display the detail of the disk sda.

Use sudo if you get Permission Denied response.

In the following example we are getting the detail of sda disk created in Oracle VirtualBox.

$ sudo hdparm -i /dev/sda

/dev/sda:

 Model=VBOX HARDDISK, FwRev=1.0, SerialNo=VBd3fcd4c7-4752b080
 Config={ Fixed }
 RawCHS=16383/16/63, TrkSize=0, SectSize=512, ECCbytes=0
 BuffType=DualPortCache, BuffSize=256kB, MaxMultSect=128, MultSect=128
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=62914560
 IORDY=yes, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 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-1,2,3,4,5,6

 * signifies the current active mode