Process Listing (ps)
Understanding the `ps` Command
The ps command is a fundamental utility in Unix-like
operating systems, including Linux, used to display information
about running processes. It allows users to monitor system activity,
identify resource-consuming applications, and manage processes
effectively. Understanding its various options is crucial for system
administration and debugging.
Common `ps` Command Usage Examples
Here are some of the most frequently used commands with
ps:
List All Processes
To list every process on the system, including those not associated
with a terminal, use the aux options:
ps aux
Display Process Tree
To visualize the process hierarchy and understand parent-child
relationships, use the axjf options:
ps axjf
Filter Processes by User
To list all processes owned by a specific user, such as 'foouser',
you can use the -au flags followed by the username:
ps -au foouser
Customizing Output Format
The ps command offers extensive formatting
capabilities. You can specify exactly which columns to display using
the -eo option, for example, to show PID, user, and the
command:
ps -eo pid,user,command
Excluding `grep` from Output
When searching for processes using grep with
ps, the grep process itself often appears
in the results. A common technique to exclude it is to use character
classes in the pattern, like [h]ttpd:
ps aux | grep '[h]ttpd'