Get Hardware Info


How To Find Out Hardware Information In A Linux System

--"-- Updated on 28th-Jul-2017 --"--

"How To Get/View Hardware Details/Information In Linux"...... How to find all hardware device details in a linux system....???? Here is the solution:
"hwlist.sh" script....

***Simple|Interactive|User-friendly|runs on RHEL7.x as well****

This script has been tested to run successfully on Linux variants such as RHEL 7/6/5, SLES 12/11, Mint16, Ubuntu 16/14, BOSS 6(Debian) etc. running on 64/32 bit architectures. It may work on other variants as well, however, not tested. These tests were run on virtual machines.

This is a small, light weight script which makes use of native Linux utilities to get the required details and doesn't need much space."

Script-Details:

Name Of The Script: hwlist.sh
Build To Run On: RHEL 7/6/5, SLES 11/12, Ubuntu 16/14 etc.,
Who Can Run This Script: Root User or sudo user.
Dependency: Packages required “dmidecode, smartmontools, sysstat”.
Output: This script when called, it would print details based on arguments passed.

What-Does-This-Do:

- Operating system (Linux) release version, kernel version, up-time details etc.
- System (server) vendor, serial number etc.
- Server main board details.
- Server BIOS glance.
- Server Processor details.
- Server physical memory (RAM) details.
- PCI devices/controllers at a glance.
- Hard disk drive details.
- Network hardware info.
- System Health Status (file system usage, top CPU/RAM consuming process etc.,)

How-Does-This-Works:
Now, the script is more user-friendly and interactive and needs an argument to be passed to the script to get details. When called without arguments it would print out a short help message as shown below:-



Get Help:- To get help on how to run this script, call the script with “--help OR --info” as an argument as shown below:-





So, pass the argument as required to the script and which would print details. For example, to print system memory (RAM) details, one could pass “--RAM OR --ram OR --memory” as shown below:-












Likewise, to get details about Operating System such as version, hardware etc, call the script with “--system” as an argument as shown :-











New Change >>> Added capability to list out multipathed drives separate from local drives as shown below:

new feature of mdisk in hwlist script added.PNG


If you wish to dump all the details into a text file for later reference or to send it somewhere else, you could do so now. To get this done, execute the script with “--dump <dumpfilelocation>” as shown below:-
#./hwlist.sh --dump /tmp/hardware.out
The above command would dump all hardware details on to file /tmp/hardware.out which is a simple text file.

Start-Download-And-Execute:

Download the script file and change permission to executable if required. Also, make sure indentation is not changed before executing this script.
#chmod u+x hwlist.sh
If you are unable to download and move this script file to your Linux system then you may need to copy the complete contents of the file as it is and paste into your file, set execute bit and run it later.

NOTE: If you copy the contents of the script manually then please keep an eye on indentation, sometimes due to incorrect indentation script would fail to run properly.

If you receive errors as shown below:

[root@localhost Desktop]# ./hwlist.sh bash: ./hwlist.sh: /bin/bash^M: bad interpreter: No such file or directory
[root@localhost Desktop]# bash hwlist.sh : command not found : command not found 'wlist.sh: line 37: syntax error near unexpected token ` 'wlist.sh: line 37: `head_fun()

Then it is because of file being moved/copied from a non-linux system to linux system, hence, there are extra characters added which bash can't understand hence, run the below command to fix it:

#sed -i -e 's/\r$//' hwlist.sh

After running the above the command, script should gets executed:

[root@localhost Desktop]# ./hwlist.sh Usage: ./hwlist.sh {--memory|--cpu|--disk|--network|--details|--system|--health|--dump <PathForDumpFile> } To get help : ./hwlist.sh --help|--info

*You may prefer to scan the download before executing on a system. You may also wish to run this on a non-production server before executing it on a production system.

View the release files:
https://github.com/SimplyLinuxFAQ/hwlist/releases

One could view/browse through the script file here, or can be copied directly from this file: https://github.com/SimplyLinuxFAQ/hwlist/blob/master/hwlist.sh

View sample text output file produced by "hwlist.sh" script when "--all" OR "--details" or "--dump" argument used:
https://github.com/SimplyLinuxFAQ/hwlist/blob/master/sample-output-file

10 comments:

Puran singh said...

Good one, thanks for sharing

Sadashiva Murthy said...

Thanks Puran.

J Balajee said...

Sir, can u give the script for shutdown all ubuntu system from server in lab send to this mail id
jbbala@gmail.com

Sadashiva Murthy said...

Balajee,

Please check my recent post: http://simplylinuxfaq.blogspot.in/2015/02/how-to-shutdown-remote-system-via-ssh-without-password.html

Thanks,
Sadashiva Murthy M

karthi said...

Hi Siva bro Nice post especially i liked your script ... Motivating too...visit my blog https://autellinux.wordpress.com/ .... I also try scripting my expectation in hardware related script filed in your blog.. thanks for your explained post

Anonymous said...

good one..

Anonymous said...

Awesome script. Could you update the script to collect temperature and fan speed?

Nazeer Qureshi said...

I am unable to run this script.

: command not found
: command not found
'wlist.sh: line 37: syntax error near unexpected token `
'wlist.sh: line 37: `head_fun()

Sadashiva Murthy said...

Please check the script file that you are running. Sometimes, when script file gets copied or moved, some extra characters gets added at the end of each line. Check this and make sure no such characters are added up. Also, make sure indentation is not altered when you copy file.

Anonymous said...

Useful script. thank you