Monday, September 10, 2012

Some of the useful Unix/Linux/Solaris Commands


To check free memory in linux: free -m

$ free -m
             total       used       free     shared    buffers     cached
Mem:          3802       3577        225          0        137       2447
-/+ buffers/cache:        993       2809
Swap:          511          0        511

The actual free memory in the RAM is 2809MB in the second line (=free+buffers+cached in the first line)
The used memory is 999MB

To check free memory in Solaris

bash-3.00$ vmstat 1 5
 kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr m0 m1 m2 m3   in   sy   cs us sy id
 0 0 0 27687376 8977832 13 109 1 2 2  0  0  1 98  2  0  538 1677 1385  4  2 94
 0 0 0 38305368 5943936 9 40 0  0  0  0  0  0  0  1  0  771 2102 1848 13  3 84
 0 0 0 38307912 5945880 116 141 0 0 0 0  0  0  0  0  0  828 2666 2155 12  6 83
 0 0 0 38307912 5945880 0 8  0  0  0  0  0  0  0  0  0  561 1030 1217  4  2 95
 0 0 0 38307912 5945880 0 4  0  0  0  0  0  0  0  0  0  561 1186 1369  5  2 93

Ignore the first line, its the value since the last reboot, here 5945880 is the free memory

Total available memory can be seen through top command

To know the CPU count in Linux

cat /proc/cpuinfo | grep processor | wc -l

Solaris:
psrinfo -pv