Friday, August 6, 2010

Handy Unix and linux commands

####################################################################

Finding CPU Information:

Solaris: /usr/platform/sun4u/sbin/prtdiag | grep 'System Configuration' | sed 's/.*(\\(.*\\) .*)/\\1/'

Linux: cat /proc/cpuinfo | grep '^model name' | sed 's/.*: //'
####################################################################

CPU Speed:
Solaris: psrinfo -v | grep MHz | awk '{print $6 $7}'

Linux: cat /proc/cpuinfo | grep '^cpu MHz' | sed 's/.*: //'
####################################################################
total Disk Space:

Solaris: /usr/sbin/df -kF ufs | grep -v Filesystem | awk '{print $2,$6}'

Linux: /bin/df -kl -x tmpfs | grep -v Filesystem | awk '{print $2,$6}'
####################################################################
Total Physical Memory
Solaris: /usr/sbin/prtconf | grep Memory | sed 's/.*: //' | awk '{print $1*1024}'

Linux: cat /proc/meminfo | grep '^MemTotal' | sed 's/.*: //' | awk '{print $1}'
####################################################################

echo $?

result of last command... 0 success and 1 failure
####################################################################
Send mail as an attachment with subject as "Logs"
uuencode log log | mailx -s "Logs" username@domain.com
####################################################################
find command with different options

find . -name "*.log" -type f -print -exec -mtime +7 gzip {} \ ; finding files with *.log and checking if older than 7 days and gzipping them

find . -name "*.log" -mtime +7 -exec rm -rf {} \; finding *.log and checking if older than 7 days and removing them

find . -size +1000m -exec ls -ltr {} \;
####################################################################
Command to clear Semaphore and Shared memory

Clear Semaphore : ipcs|grep ^s|awk '{print "ipcrm -s " $2}'|sh
Clear Shared memory : ipcs|grep ^m|awk '{print "ipcrm -m " $2}'|sh
Check semaphore and shared memory: ipcs
####################################################################

screen -S backup -t backup

screen -d -r pid.backup
####################################################################

tar cf - dir/ | gzip -c > file.tar.gz
####################################################################
kill all the httpd process

ps -ef | grep httpd | sed -e '/grep/d' | awk '{print $2}'|xargs kill -9
####################################################################
Simple for loop to check the remote hostname and output of the command

for i in a b c; do ssh apache@server${i}col "echo \"Host: server${i}col\";ls -ltr /tmp";done
####################################################################
Command to check Processor 32 or 64 bit

Solaris: isainfo -b
Linux : uname -a
x86_64 and ia64 are 64 bit , if i386 is 32 bit
####################################################################

###################################################
AIX command to check machine name.
###################################################

/opt/local/bin/nmon -r -t
###################################################
AIX command to check CPU name.
###################################################

topas
vmstat --- for memory
###################################################
Command to check WLM on AIX
###################################################

smitty
wlmstat

No comments:

Post a Comment