We know that the ‘ps’ command in Linux is used to display information about active processes. Let us explore few more options that ps has to offer.
1. ps: By itself, this command shows processes for the current shell.
2. ps -A or ps -e: Shows all processes on the system.
3. ps -u username: Shows processes owned by the specified username.
4. ps -f: Provides a full-format listing. This includes additional details like the UID, PID, PPID, start time of the command, etc.
5. ps -l: Provides a long-format listing. This includes additional details like the process priority, nice value, and more.
6. ps -x: Shows processes not attached to a terminal. This can be useful for seeing background processes.
7. ps -T: Shows all threads for a process. Useful for multi-threaded applications.
8. ps -aux: This is a combination of several options:
– a: Shows processes for all users.
– u: Shows user/owner information.
– x: Shows processes not attached to a terminal.
The output includes details like the CPU and memory usage, process status, start time, and more.
9. ps -eo: Allows custom formatting. After `-eo`, you can specify the fields you want, e.g., `ps -eo pid,cmd,%cpu,%mem` would show the process ID, command, CPU, and memory usage.
10. ps –forest: Displays processes in a hierarchical format (i.e., in a tree structure), which is useful for seeing parent-child relationships.
11. ps -C cmd: Lists processes with the specified command name. For example, `ps -C bash` would show all `bash` processes.
12. ps -p PID: Lists processes with the specified process ID.
13. ps -N: Negates the selection. For example, `ps -N -U root` would show all processes not owned by the root user.
14. ps –sort: Sorts the output based on the given criteria. For instance, `ps aux –sort=-%mem` would sort the processes based on memory usage in descending order.
15. ps -o format: This displays the process information based on a user-defined format. For example, ps -o pid,comm,cmd,start will show the process ID, the command name, the full command line, and the start time of the command.
16. ps -S: Displays the CPU time of both the process and its children.
17. ps -q pid: This will display the process information in a quick PID format. It’s a shorter way of displaying process info for a given PID.
18. ps –cumulative: Includes child processes to be counted in CPU and time statistics.
19. ps –lines n: Specifies the number of lines of the output. Useful when tailoring the output for specific screen or file sizes.
20. ps -F: Provides an “extra full” format listing, showing even more details than -f.
You can explore more options just by typing ‘man ps‘ on bash.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
An Article by: Yashwanth Naidu Tikkisetty
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
