Useful Commands

1. To get IP Address of Machine.

#ifconfig eth0| grep "inet addr:"|cut -c '21-35' 

# ifconfig eth0| grep "inet addr:"|awk -F ":" '{print $2}'|cut -d " " -f 1

# ifconfig eth0 |grep "inet addr:"|cut -d: -f2|awk '{print $1}'

2. To get Hardware (MAC) address of Ethernet Device.

#ifconfig eth0| grep "HWaddr"|cut -c '39-55'

#ifconfig eth0| grep "HWaddr"|awk -F " "  '{print $5}'

3. To get load average at 1min, 5min and 15min.

# echo "Load1Min: `uptime |awk -F "load average:" '{print $2}'|cut -d, -f1|sed "s/ //g"`"
Load1min: 5.01

# echo "Load5Min: `uptime |awk -F "load average:" '{print $2}'|cut -d, -f2|sed "s/ //g"`"
Load1min: 2.21

# echo "Load15Min: `uptime |awk -F "load average:" '{print $2}'|cut -d, -f3|sed "s/ //g"`"
Load1min: 1.01

4. To get Memory usage in readable format.

#free -tom | awk '/Total:/ {print "Total memory: "$2" MB\nUsed memory: "$3" MB\nFree memory: "$4" MB"}'

Total Memory: 1503 MB
Used Memory: 2 MB
Free Memory: 1501 MB

No comments:

Post a Comment