ps while being only two letters is a massively complex, complicated and powerful tool.

per default it outputs all running processes sorted for Process ID (PID) but you can change that sorting.

here are the “ps info page/man”

ps.info.txt (2011)

man.ps.txt (2020)

ps --help all; # gives detailed info about usage

and some help instructions:

ps-help-all.txt

examples:

ps uax|less; # show all running processes

ps uax --sort %mem|tail; # what process is using most of the RAM?
ps axjf; # print process tree, also very nice

# in different formattings
ps -e|less
ps -ef|less
ps -eF|less
ps -ely|less

# To see every process on the system using BSD syntax:
ps ax|less

ps uax|wc -l
129 <- roughly (not exactly) 129 processes active
ps jaxkuid,-ppid,+pid|less; # sort by
ps axk comm o comm,args|less
ps kstart_time -ef|less

ps kstart_time -ef|less; # sort by start time of process

sorts for “CPU/RAM/CPU-TIME USAGE”

ps uax --sort cputime|less; # sort processes for cpu time (cumulated cpu usage)
ps uax --sort %cpu|less; # sort for current cpu usage
ps uax --sort %mem|less; # sort for current ram usage

keys you can sort for: (some keys not available for sorting)

sort and format output of ps

ps -eo pmem,pcpu,rss,vsize,args --sort %mem|less;
# will display
# 1. in the first row mem in percent (pmem)
# 2. in the second row current cpu usage in percent (pcpu)
# 3. in the third row will display cpu usage in percent (pcpu)
# 4. in the fourth row display "resident set size"
# rss RSS resident set size, the non-swapped physical
# memory that a task has used (inkiloBytes).
# (alias rssize, rsz).

# 5. in the fifth row display "virtual memory size"
# vsz VSZ virtual memory size of the process in KiB
# (1024-byte units). Device mappings are currently
# excluded; this is subject to change. (alias vsize).
# args = display the arguments the process was started with
# --sort %mem; -> sort the whole thing for percentage of ram used by the process

alternative: top: sorts for “CPU/RAM/CPU-TIME USAGE”

# live monitoring of CPU usage
top -o %CPU;

# output CPU usage to file
top -b -n1 -o %CPU > cpu.usage.log;

# live monitoring of RAM usage
top -o %MEM;

# output RAM usage to file
top -b -n1 -o %MEM > ram.usage.log;

# live monitoring of what process used most CPU-TIME
top -o TIME+;

# output of what process used most CPU-TIME
top -b -n1 -o TIME+ > cpu_time.usage.log;

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin