Pages

Saturday, February 9, 2013

Unix Command Shortcuts

Unix Grep and Kill process in one line

kill -9 `ps -ef | grep ppp | awk '{ print $2 } ' (This command will search for process called ppp and kill all instance of ppp)



macaddress=`cat /sys/class/net/eth0/address`  (store mac address in variable)
currentip=`ifconfig eth0 | grep "inet addr" | awk -F: '{ print $2 }' | awk '{ print $1 }'` (store ip address in variable)
currentsubnet=`ifconfig eth0 | grep "inet addr" | awk -F: '{ print $4 }' | awk '{ print $1 }'` (store subnet in variable)

No comments:

Post a Comment