Monday, March 28, 2011

Knowing your System in Linux

Recently I was in a situation where it was required to find out the software/ application and hardware details for my ubuntu10.10 and to my surprise there was no single place where i could find the list of commands which can give me complete information.

It might be because of my short experience with linux but I am sure that lot of people (like me :)) do a googling to find out the correct information.

So thought of compiling all information at one place: -



lshw - list Complete Hardware information about your system

Logging in to root and just typing "lshw" will provide the complete information about the Hardware of your system.
To get more Specific info use the following Commands

lshw -class memory
lshw -class cpu
lshw -class disk
lshw -short


cat /proc/*

Another powerful command to get the detailed information about the system

cat /proc/cpuinfo - Provides info about your CPU
cat /proc/meminfo - provides info about your Memory

sginfo - access mode page information for a SCSI (or ATAPI) device

In case this command is not available than install sg3-utils "apt-get install sg3-utils"

All information around the various arguments for this command can be found here

hdprm - Another prowerfull command for not only getting your Drive information but also can be used to tune your Drive

hdparm /dev/hda - gives the information about the drive
hdparm -Tt /dev/hda - used for getting the read and write speed of yur drive


Some more useful monitoring commands: -

iostat -c -k -p -d 2

What does it means: -

–c = Display the CPU utilization report.
–d = Display the device utilization report
–k = Displays utilization in KB/sec (use –m per sec)
–p = Displays Stats for all devices and partitions
–d = device utilization report
2 = displays the same report after every 2 seconds

mpstat -P ALL 2 5

The above command will provide the 5 reports for "average CPU utilization" for all the available processors in interval of 2 seconds

Total number of CPU's

grep core\ id /proc/cpuinfo | grep -c \ 0$ | grep ^0$ >> /dev/null && grep -c processor /proc/cpuinfo || grep core\ id /proc/cpuinfo | grep -c \ 0$

Sockets/ FD (File Descriptors)

There are n number of of powerful commands which can give the full details about the Sockets or FD's open in my Linux Box. Below are few of them

#Maximum number of open files:
cat /proc/sys/fs/file-max

#Allocated, free allocated, and max FDs:
cat /proc/sys/fs/file-nr

#Max threads:
cat /proc/sys/kernel/threads-max

#Max half-open TCP:
cat /proc/sys/net/core/somaxconn

#Upper limit for the number of sockets which can be opened by all the processes
ulimit -a

#Modify the below configuration file to impose the max number of sockets for a user
/etc/security/limits.conf

#Count of total FD's open by a process
cat /proc/<pid>/fd/ | wc -l
lsof | grep <pid> | wc -l

#Details about all FD's open by a process
lsof | grep <pid>

No comments: