Friday, August 24, 2012

Process Based Commands

Some Process Based Commands (Updated Regularly)

List the Process based on the UID and Commands
ps -f -u wwwrun,postfix
List process based on Commands
ps -aux | grep command
ps -f -C (find Process by

List the processes based on PIDs or PPIDs
ps -f --ppid

List Processes in a Hierarchy
ps -e -o pid,args –forest

Get Details of the Process
ps -L -p -o pid,lwp,pcpu,cputime,fname

Get Details of a Specific Process
ps -u dwls651 -o uname,pid,thcount,comm | grep java

List all threads for a particular process     
ps -C java -L -o pid,tid,pcpu,state,nlwp,args

Outputs the highest %MEM at bottom
ps aux --sort pmem (see the %MEM column)

find out which cpu processor a process is running on    
ps -eo pid,args,psr

Lists all current processes for the user named username in full listing format 
ps -f -u username
Return Number of kernal Threads Owned by a process
ps -o thcount -p
Display the top running process according by memory usage
ps aux | sort -nk +4 | tail
Process List By User
ps hax -o user | sort | uniq -c

Show all process by their memory & CPU Usage
ps aux --sort=%mem,%cpu
Show How much memory a Fire Fox (or Process) is using
ps -o %mem= -C firefox
View Process by Hierarchy , allows us to know what needs to be killed
ps -Hacl -F S -A f
Current Running Shell
ps -p $$

List Process By Highest CPU Usage
ps -ef --sort=-%cpu

Display Date of the Process Started
ps -o lstart

List Threads By PID along with Thread Start Time
ps -o pid,lwp,lstart --pid –L

Top Memory Usage
ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS

print a stack trace of a running process

Find Information abt the Parent Process
ps -o ppid= | xargs ps –p

Count Threads OF a JVM Process
ps uH p | wc –l

Kill Zombie process
kill -9 `ps -xaw -o state -o ppid | grep Z | grep -v PID | awk '{print $2}'`
 Happy Learning , More To Come.