How to check the hardware information in Linux Systems?

There are many commands to check information about the hardware of your Linux system like CPU or memory etc. The list includes lscpu, dmidecode, lspci etc.

1).lscpu

It gives info about CPU and processing units as below.


2).lspci:

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.



you can also specific devices you want as below...

[root@www ~]# lspci -v | grep -i ide
00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01) (prog-if 8a [Master SecP PriP])

[root@www ~]# lspci -v | grep -i USB
02:00.0 USB controller: VMware USB1.1 UHCI Controller (prog-if 00 [UHCI])
02:03.0 USB controller: VMware USB2 EHCI Controller (prog-if 20 [EHCI])
        Subsystem: VMware USB2 EHCI Controller

[root@www ~]# lspci -v | grep -i vga
00:0f.0 VGA compatible controller: VMware SVGA II Adapter (prog-if 00 [VGA controller])
        Subsystem: VMware SVGA II Adapter
[root@www ~]#

3).lsblk:

Which list outs the block devices.

[root@www ~]# lsblk
NAME                MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0                  11:0    1 1024M  0 rom
sda                   8:0    0   38G  0 disk
sda1                8:1    0  300M  0 part /boot
sda2                8:2    0  3.4G  0 part [SWAP]
sda3                8:3    0 34.3G  0 part /
sdb                   8:16   0    2G  0 disk
vgbk-lvbk (dm-0)  253:0    0  200M  0 lvm  /java/oracle
vgbk-lvbk2 (dm-1) 253:1    0  300M  0 lvm  /java/sybase
[root@www ~]#

4).lshal:

It list outs the HAL devices as below.

HAL (Hardware Abstraction Layer or rather Hardware Annotation Library) was a software subsystem for UNIX-like operating systems providing hardware abstraction.



5).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

[root@www ~]# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
You have new mail in /var/spool/mail/root
[root@www ~]#


6).df :

disk space of file systems

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


[root@www ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              34G  3.2G   29G  10% /
tmpfs                 867M   72K  867M   1% /dev/shm
/dev/sda1             291M   33M  243M  12% /boot
/dev/mapper/vgbk-lvbk
                      194M  5.6M  179M   4% /java/oracle
/dev/mapper/vgbk-lvbk2
                      291M   11M  266M   4% /java/sybase
.host:/               238G  181G   58G  76% /mnt/hgfs
[root@www ~]#


7.fdisk:

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


8).mount:

The mount is used to mount/unmount and view mounted file systems(ext2,ext3....etc)

[root@www ~]# mount
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/mapper/vgbk-lvbk on /java/oracle type ext3 (rw)
/dev/mapper/vgbk-lvbk2 on /java/sybase type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
.host:/ on /mnt/hgfs type vmhgfs (rw,ttl=1)
vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
You have new mail in /var/spool/mail/root
[root@www ~]#

If you want the output in column-wise you have to use column -t as below.


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



9).free - Check RAM:

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

 free -m gives the size in Mega Bytes.

10).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).
If you give dmidecode command in the command_line you will get all the information about the System bios,cache,memory,architecture etc as below....


If you want particular information then you have to use like dmidecode -t processor, dmidecode -t cache , dmidecode -t memory as below

Processor info:

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


Memory info:

# memory/ram information
#dmidecode -t memory



Cache info:


# cache details
#dmidecode -t cache




11). /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

[root@www ~]# cat /proc/version
Linux version 2.6.32-358.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Fri Feb 22 00:31:26 UTC 2013
[root@www ~]#




SCSI/Sata devices

$ cat /proc/scsi/scsi 

[root@www ~]# cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
  Type:   CD-ROM                           ANSI  SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: VMware,  Model: VMware Virtual S Rev: 1.0
  Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi2 Channel: 00 Id: 01 Lun: 00
  Vendor: VMware,  Model: VMware Virtual S Rev: 1.0
  Type:   Direct-Access                    ANSI  SCSI revision: 02
[root@www ~]#

Partitions

[root@www ~]# cat /proc/partitions
major minor  #blocks  name

   8        0   39845888 sda
   8        1     307200 sda1
   8        2    3571712 sda2
   8        3   35965952 sda3
   8       16    2097152 sdb
 253        0     204800 dm-0
 253        1     307200 dm-1
[root@www ~]#


12).hdparm - get/set SATA/IDE device parameters

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

[root@www ~]# hdparm -i /dev/sdb

/dev/sdb:
 HDIO_DRIVE_CMD(identify) failed: Invalid exchange
 HDIO_GET_IDENTITY failed: Invalid argument
[root@www ~]# hdparm /dev/mapper/vgbk-lvbk

/dev/mapper/vgbk-lvbk:
 HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device
 readonly      =  0 (off)
 readahead     = 256 (on)
 geometry      = 0/0/0, sectors = 409600, start = 0
You have new mail in /var/spool/mail/root
[root@www ~]#



Comments

  1. You do realize that your hdparm commands failed, right?

    ReplyDelete
    Replies
    1. Looks like he just copy from somewhere then paste it to his blog without even try those command.

      Delete

Post a Comment

Popular posts from this blog

Ansible for Devops

python in liunx