Friday, January 17, 2014

Report A Snapshot of Current Processes

ps [options]

ps displays information about a selection of the active processes. It accepts several kinds of options:

  1. UNIX options, which may be grouped and must be preceded by a dash.
  2. BSD options, which may be grouped and must not be used with a dash.
  3. GNU long options, which are preceded by two dashes.

 To see every process on the system using standard syntax:
ps -eps -efps -eFps -ely

 To see every process on the system using BSD syntax:
ps axps axu

 To print a process tree:
ps -ejHps axjf

 To get info about threads:
ps -eLfps axms

 To get security info:
ps -eo euser,ruser,suser,fuser,f,comm,labelps axZps -eM

 To see every process running as root (real & effective ID) in user format:
ps -U root -u root u

To see every process with a user-defined format:
ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,commps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,commps -eopid,tt,user,fname,tmout,f,wchan

Print only the process IDs of syslogd:
ps -C syslogd -o pid=

Print only the name of PID 42:
ps -p 42 -o comm=