ps shows a list of processes in a unix system.

Examples

show the exact command used to start all process

ps axwwo command

show a process tree view

ps auxf

show only all running processes

This excludes sleeping processes and threads.

ps auxr

Show process list sorted by process start time

ps hax -o lstart,pid,args |
  while read -r a b c d e f g ; do
    echo "$(date -d "$a $b $c $d $e" "+%F %T%z") $f $g" ;
  done |
  sort

Show all processes not owned by a user, and no threads, including cgroup name

  • -N after a condition makes hides the results of that condition
  • All linux kernel threads have parent pid 2 (kthreadd)
FILTERED_USER=zerocool # user must exist
ps -o pid,ppid,user,comm,flags,%cpu,sz,%mem,cgname --user "${FILTERED_USER}" -N --ppid 2 -N