Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

ps Cheatsheet

📅 2016-Sep-27 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

ps is the classic Unix/Linux command to list processes and their details. ps that ships with Linux is super-confusing to use because it supports three types of arguments: Unix options (-u), BSD options (x) and GNU options (--pid). The format of the display will also be different based on which type of option you use! I wish the Linux ps did not have so much backward compatibility and was as simple as the OpenBSD ps.

$ ps

This would have been useful many years ago, when Unix users put running programs to background and switched them back to foreground later. Today most Linux users just open multiple terminals to achieve the same, so this invocation is pretty useless.

Note that is lists the process ID (PID), the terminal of the process (TTY), time it has consumed (TIME) and the command invoked to start the process (CMD).

$ ps 9999
$ ps a
$ ps ax
$ ps -e
$ ps aux
$ ps -ef

Note that this command might be a bit slow since it needs to convert UIDs to usernames.

$ ps lax
$ ps elf
$ ps a --forest
$ ps eww 9999
$ ps -o user,pid,time,cmd