Basic diagnosis commands in solaris and in linux
1. To check icmp request
ping -s hostname (Solaris)
2. To view load, cpu usage and memory usage
top and press M (Linux)
prstat or prstat -a or prstat -p <pid> -L (Solaris)
ps -eo pcpu,pid,user,args| grep process | sort -r -k1
3. To view size of physical memory
free -m
prtconf -pv | grep Memory
4. To view cpu information
more /proc/cpuinfo
psrinfo
5. To view info about particular port or open session on a port or routing table
netstat -ntpl [linux]
netstat -f inet -an|grep LISTEN [view the list of port open on the host]
netstat -an| grep ‘ESTABLISHED’ [view different conn established on different port]
netstat -an| grep ‘ESTABLISHED’| grep ‘ip.port’ [same as above]
netstat -nr [view routing table]
6. To check wheter port is alive or not
telnet ip port
7. To compress or uncompess a file
gzip filename
gunzip -c file.gz| tar xvf -
tar zxf file.tar.gz or gtar zxf file.tar.gz
8. To determine route of a request
traceroute <ip or hostname>
9. To view a particular process is running or not and its argument
ps -ef | grep process
pargs <PID>
10. Remove or replace with find
find . -name ".mp3" -exec rm -f {} \; [find the .mp3 file and then remove them]
find ./ -name ‘*.clm’ -exec mv {} {}\.txt \; [find all .clm file & then move all to .txt]
11. Matching pattern using grep
grep abc /etc/passwd [match whether 'abc' exists or not]
grep -R -l ‘clamav’ /usr/share/doc [List the file names of all files that contains clamav under /usr/share/doc ]
grep “2008-07-17\ 13:[1-5][0-9]:[0-5][0-9]” [Matching lines using regular expression]
12. Text formatting
delete trailing whitespace (spaces, tabs) from end of each linesed 's/[ \t]*$//'delete BOTH leading and trailing whitespace from each linesed 's/^[ \t]*//;s/[ \t]*$//
