Check the hardware and system information in Linux.

Today we will learn how to check the hardware and System information in Linux, so we will divide this section of the hardware commands and System commands.

It is very important to know, which hardware you are running on your system.

We have seen the various commands in the previous blogs, So we will see all the commands in summary.

The commands we see today are dmidecode, lshw, lscpu, lsusb, lsblk, fdisk, blkid, du, df, and free command which will be used to check the hardware in Linux.

So, for the System information, we will look in the uname command in Linux.


FOR SYSTEM INFORMATION

A cheat sheet of uname command in Linux
How to find all information about system

Command:
#uname -a
How to get Kernal Name

Command:
#uname -s
How to get Network node hostname

Command:
#uname -n
How to get information about kernel release.

Command:
#uname -r
How to get kernel version.

Command:
#uname -v
How to get Machine Hardware Name.

Command:
#uname -m
How to get Processor type.

Command:
#uname -p
How to get Hardware Platform.

Command:
#uname -i
How to get Operating System.

Command:
#uname -o

Refer this command to Check the uname in Detail


dmidecode command in Linux

FOR ALL HARDWARE

This command collects the data from the system and represents it in the human-readable format.

The dmidecode full form is Desktop Management Interface table decoder

dmidecode command cheat sheet
How to check uuid of the system

Command:
# dmidecode -s system-uuid
How to check Serial Number of the system

Command:
# dmidecode -s system-serial-number
How to check Processor Family of the system

Command:
# dmidecode -s processor-family
How to check Processor Version of the system

Command:
# dmidecode -s processor-version
How to check BIOS Information of the system

Command:
# dmidecode -t BIOS
How to check the Detail about System

Command:
# dmidecode -t system
How to check the Detail about the CPU 

Command:
# dmidecode -t processor
How to check the Detail about the Memory 

Command:
# dmidecode -t memory

Refer this command to Check the dmidecode in Detail


lshw command in Linux

FOR THE LIST OF HARDWARE

lshw command is mainly used to check the list of hardware and Configuration in your server and PC.

In some of the flavour lshw command is not install.

So, you can install lshw command using the package Manager.

For RedHat Family:

#yum install lshw -y

For Debian Family:

#apt install lshw
lshw command in Linux cheat sheet
To List all the HARDWARE in your current System

Example:
#lshw
To make the output short with lshw command 

Example:
#lshw -short 
To search by the TYPE of Hardware 

Example:
#lshw -class cpu          ** This is for CPU **
#lshw -class memory  ** This is for RAM **
#lshw -class disk          ** This is for DISK **
#lshw -class volume    ** This is for partition **
#lshw -class network  ** This is for Network **
To hide the sensitive Information like serail number. 

Example:
#lshw -sanitize
#lshw -class cpu -sanitize 
#lshw -class memory -sanitize 
#lshw -class disk  -sanitize
#lshw -class volume  -sanitize
#lshw -class network  -sanitize
To get the output in HTML Format 

Example:
#lshw -html

** To take a html format in one file **
#lshw -html > hardware_list.html 
To get the output in XML Format 

Example:
#lshw -xml

** To take a xml format in one file **
#lshw -xml > hardware_list.xml 
To get the output in JSON Format 

Example:
#lshw -json

** To take a json format in one file **
#lshw -json > hardware_list.json 

Refer this command to Check the lshw in Detail.


lscpu command in Linux

FOR CPU

lscpu command is used to display the information about the CPU architecture.

This command gathers the information from /proc/cpuinfo file.

# lscpu |grep "Model name"
Output:
Model name: Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz

So, you can check the Model Number by using grep command.


fdisk command in linux

FOR HARD DRIVE DISK (HDD)

It is mainly used for the creation and manipulation of the Partitions.

This fdisk command understands the partition tables like GPT, MBR, Sun, SGI, and BSD.

So, we can manage our disk partitions like create, update and delete. The block Devices can be divided into one or more logical disks known as Partitions.

A cheat sheet of fdisk command in Linux.
Q. How we can list the partition in the disk using fdisk.

Syntax:
#fdisk -[option]

Command:
#fdisk -l
Q. How we can list the partition of a particular Disk.

Syntax:
#fdisk -[option] [disk_partion]

Command:
#fdisk -l  /dev/sdb
Q. How we can see a Colourful output.

Syntax:
#fdisk -[option]=[never/always/auto]

Command:
# fdisk -l -L=never
# fdisk -l --color=always
Q. How to get the output of a specific column using fdisk command in Linux.

Syntax:
#fdisk -[option] -o [cloumn_name]

Command:
# fdisk -l -o Device,UUID,Size,type
Q. How to get the size of disk and from its partitions.

Syntax:
#fdisk -[option] [disk/disk_partition]

Command:
# fdisk -s /dev/sda
# fdisk -s /dev/sda1
Q. How to get the disk details by its disk label type.

Syntax:
#fdisk -[option] [disk_label]

Command:
# fdisk -l -t gpt
Q. How to get the output by it's units with fdisk command.

Syntax:
#fdisk -[option]=[units]

Command:
# fdisk -l -u=sectors
# fdisk -l -u=cylinders

Refer this command to Check the fdisk in Detail.


du command in Linux

FOR DISK

So, this is mainly used to check the space usage of the files and folders. We can check the size of files and folders in the disk space.

With the help of this, we can keep easily track the size of the files and folder.

du commands in Linux cheat sheet
To check the size of files and folder in human readable format

Syntax:
du [option] [argument]

Example:
#du -h files
#du -h folders
To check the output in a single line.

Syntax:
du [option]

Example:
#du --null
#du -0
To check all files and folder in Linux.

Syntax:
du [option]

Example:
#du -a
#du --all
To check all files and folder in Block size.

Syntax:
du [option] [argument]

Example:
#du -B k  -- o/p will be in KB.
#du -B m -- o/p will be in MB.
#du -B g  --  o/p will be in GB.
To check the total size of the current directory.

Syntax:
du [option]

Example:
#du -c
#du --total
To check the depth or level for a directory .

Syntax:
du [option] [levels]

Example:
#du -d 1 -- for level one directory.
#du -d 2 -- for level two directory.
#du -d 3 -- for level three directory.
To check the inodes instead of block size.

Syntax:
du [option]

Example:
#du --inodes
To check the size of it's directory only not it's sub-directory.

Syntax:
du [option]

Example:
#du -S
Displat only the total of an each arugment.

Syntax:
du [option]

Example:
#du -s
To Set the threshold size  

Syntax:
du [option] [size]

Example:
#du -t 5k //Show only those files and folders whose size is greater that 5 KB.  
#du --threshold=10k //Show only those files and folders whose size is greater that 10 KB.
To show the modification time with size.

Syntax:
du [option] [size]

Example:
#du --time
To exclude the size of the file.

Syntax:
du [option]=[directory]

Example:
#du --exclude=level_1

Refer this command to Check the du in Detail.


df command in Linux

FOR DISK

df command in Linux with options and their examples. The df command is used to check the System disk space usage

These commands show us the total size, used, and available on the connected system Drive.

A cheat sheet of df command in Linux
1. To check the Disk Space.

Example:
#df 
2. To check the Disk Space in human readable format.

Syntax:
df [option]

Example:
#df -h
3. To check the type of file System.

Syntax:
df [option]

Example:
#df -T
4. To check with particular file system.

Syntax:
df [option] [arugment]

Example:
#df -t ext4
#df -t xfs
5. To exculde the particular file type.

Syntax:
df [option] [argument]

Example:
#df -x ext4
6. To show the output in inodes instead of Block size.

Syntax:
df [option]

Example:
#df -i
7. To show the output as a particular field.

Syntax:
df [option]=[field1,field2,field3...]

Example:
#df --output=size,used,avail
8. To check the Block size in KB, MB and GB.

Syntax:
df [option] [argument]

Example:
#df -B k
#df -B m
#df -B g

Refer this command to Check the df in Detail.


free command in Linux

FOR RAM (MEMORY)

free command, which is mainly used in Linux and Unix OS to check the usage of memory on Server and Desktop.

So, we can use the free command in Linux with example and check the current usage, swap space, total available memory, cache memory, and many more parameters.

free command cheat sheet
1. How to check RAM size in kibibytes.

Example:
#free -k
2. How to check RAM size in kilobytes.

Example:
#free --kilo
3. How to check RAM size in mebibytes.

Example:
#free -m
4. How to check RAM size in megabytes.

Example:
#free --mega
5. How to check RAM size in gibibytes.

Example:
#free -g
6. How to check RAM size in gigabytes.

Example:
#free --giga
7. How to check RAM size in human readable format.

Example:
#free -h
8. How to check RAM size in terabytes and petabytes.

Example:
#free --tera  //for terabytes
#free --peta //for petabytes
9. How to check RAM utlization in every seconds

Example:
#free -s
10. How to check RAM utlization in every 5 seconds till 10 count

Example:
#free -s 5 -c 10

Refer this command to Check the df in Detail.


lsusb command in Linux

FOR USB

It is used to check the USB devices in to your system.

$ lsusb -t

So, this command shows that my system has two USB ports in my system.


lsblk command in Linux

FOR BLOCK DEVICES

So, it will list all the information about the available or the specified block devices.

lsblk
#lsblk

So, as you can see that this is showing two HDD with there partitions, mount points, and the size of the Disk also.


blkid command in Linux

FOR BLOCK DEVICES ID

So, blkid command is used to find the UUID of the block devices.

Check the UUID to permanent Mount

So, friends we have check the block ID of /dev/sdb1, if you will use the “blkid command” it will show the output of all the block devices you have in your current System.


Thanks for reading the Post. Keep Supporting Friends, Subscribe to get daily updates.

For practise you can use the following link.

3 Replies to “Check the hardware and system information in Linux.

Give your valuable time