ps command examples

– ps is an extensively used command in Linux environment to track/get the processes for any kind of troubleshooting.

– It is very versatile command to get the many stats for processes from the OS.


1. To see the zombie process



                # ps aux | awk ‘{ print $8 ” ” $2 }’ | grep -w Z


2. Listing zombie processes



                # ps -el | grep Z


3. To find/list the running processes



                # ps -r


4. Find processes for a particular user


                # ps -U apache
                # ps U apache

                # ps -u apache


5. To see every process running as root (real & effective ID) in user format:



                # ps -U root u


6. To find/list the processes which has tatad.pl in its command execution?



                # ps -f -C tatad.pl

7. List the processes based on PIDs



                # ps -f –ppid 9576



8. pgrep, pkill – look up or signal processes based on name and other attributes


                # pgrep 1234

                # pkill 1234 OR # pkill httpd


9. Sorting the ps output



                # ps -eo uname,pid,ppid,nlwp,pcpu,pmem,psr,start_time,tty,time,args –sort -pcpu,-pmem


10. To print a process tree:


              # ps -ejH

              # ps axjf


11. Print only the process IDs of syslogd:



              # ps -C syslogd -o pid=


12. Print only the name of PID 42:



              # ps -p 42 -o comm=


13. List the Process based on the UID and Commands



               # ps -f -u wwwrun,postfix


14. List the processes based on PIDs or PPIDs


               # ps -f –ppid 9576


15. List Processes in a Hierarchy



                #  ps -e -o pid,args –forest

16. List elapsed wall time for processes



                # ps -p 1,29675 -o pid,etime=



17. To list the process hierarchy


                # ps -e -o pid,args –forest
                # ps axjf

                # ps -ejH


18. List all threads for a particular process



                # ps -C java -L -o pid,tid,pcpu,state,nlwp,args


19. To display a tree of processes.



                # pstree


20. To list elapsed wall time for processes



                # ps -p 1,29675 -o pid,etime=


21. ps command is most extensively used to get/fetch the processes running on the Linux/UNIX systems.


22. To get the process start time



                # ps -p PID -o lstart=

23. Display full information about each of the processes currently running.



                # ps -ef | grep



24. To get info about threads:


                # ps -eLf

                # ps axms


25. To get security info:


                # ps -eo euser,ruser,suser,fuser,f,comm,label
                # ps axZ

                # ps -eM


26. To see every process with a user-defined format:


                # ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
                # ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm

                # ps -eopid,tt,user,fname,tmout,f,wchan


27. List all threads for a particular process



                # ps -C java -L -o pid,tid,pcpu,state,nlwp,args

Leave a Reply

Your email address will not be published. Required fields are marked *