Monday, January 4, 2010

Solaris Tips

Find a process taking up a particular port :

for i in `ps -eawk '{print $1}'`; do echo $i; pfiles $i 2>/dev/null grep 'port: 1188'; done

This loop will go all the process and print the process id of the process which is consuming this particular port.

Useful oneliners:
Count total number of lines in all specific files under a directory : find . -type f -name '*.as' -o -name '*.mxml' -o -name '*.java' xargs cat wc -l
Find number of occurrences of a text in a file : grep text fileName wc -l
Display the top most process utilizing most CPU (top -b 1)
Show the working directory of a process : (pwdx pid )
Display the parent/child tree of a process : (ptree pid )
Display the no.of active established connections to localhost : netstat -a grep ESTABLISHED
Display the largest files/directories in order of size: du -sk * sort -nr
Display the files in the directory by file size : (ls -ltr sort -nr -k 5)
Display the all files recursively with path under current directory : ( find . -depth -print)
To save man pages to a file use : man col -b > filename

No comments:

Post a Comment