ps is an essential utility that allows users to view information about current processes. The ps command provides a snapshot of the current state of the system, showing which processes are currently running, their status, their process ID (PID), and other helpful details.
Basic Syntax
ps [options]
Commonly Used Options
-
-a: Display information about all processes associated with terminals, including those that are not associated with the current terminal session. -
-x: Display information about all processes, including those not attached to a terminal session.
-
-e: Display information about all processes. -
-o: Uses column header keywords. -
-f: Display a full-format listing. -
-l: Display a long-format listing. -
-u: Display information about processes owned by a specific user. -
-p: Display information about a specific process. -
--sort=: Sort specifier
Column Headers
The ps command in Linux provides a wide range of column headers that can be displayed to provide detailed information about running processes.
-
USER: The user who started the process. -
PID: The unique process ID. -
%CPU: The percentage of CPU time the process has used. -
%MEM: The percentage of physical memory the process has used. -
VSZ: The virtual memory size of the process. -
RSS: The resident set size (i.e., the amount of physical memory) the process is using. -
TTY: The controlling terminal for the process. -
STAT: The current status of the process. -
START: The time the process started. -
TIME: The amount of CPU time the process has used. -
COMMAND: The command used to start the process.
Examples of Using ps Options
-
ps -ef: Displays a full-format listing of all processes running on the system, including information about the user who started the process, the process ID, the CPU and memory usage, and the command used to start the process. -
ps -eo pid,user,uid,gid,vsz,comm --sort=vsz: Displays a list using custom headers, sorting the list in descending order for virtual memory allocation. -
ps -l: Displays a long-format listing of all processes running on the system, including information about the user who started the process, the process ID, the CPU and memory usage, and the command used to start the process. -
ps -u username: Displays information about all processes owned by a specific user. -
ps -p pid: Displays information about a specific process, identified by its process ID. -
ps -ax: Displays information about all processes, including those not attached to a terminal session. -
ps -ef | grep processname: Displays information about all processes running on the system, and then uses thegrepcommand to filter the output to show only processes that contain the specified process name. This can be useful for finding specific processes that may be causing issues on the system. -
ps aux --sort=-%mem: Displays a detailed listing of all processes running on the system, sorted by the percentage of physical memory they are using (with the highest usage at the top of the list). This can be useful for identifying processes that may be consuming too much memory and causing performance issues. -
ps -e --forest: Displays a tree-like structure of all running processes, showing their relationships to one another. This can be useful for understanding how processes are connected and identifying any parent or child processes that may be causing issues.
Leave a Reply