Enhancing Skills

ps: Display a snapshot of currently running processes

Command: ps

The ps command provides a snapshot of the current processes running on the system. It shows information like process IDs (PIDs), user ownership, CPU usage, memory usage, and more. The output can be filtered and formatted using various options to display specific details.


Sample Command and Output:

$ ps
  PID TTY          TIME CMD
 1234 pts/0    00:00:00 bash
 1235 pts/0    00:00:01 ps

Description:

  • PID: Process ID, a unique identifier for each running process.
  • TTY: Terminal associated with the process.
  • TIME: Amount of CPU time used by the process.
  • CMD: Command that started the process.

Additional Commands and Sample Outputs:

  • ps aux: Displays detailed information about all processes, including those not attached to a terminal. Sample Command and Output:
  $ ps aux
  USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
  root         1  0.0  0.1  16808  1484 ?        Ss   Aug09   0:01 /sbin/init
  davidq    1234  0.0  0.3  12036  3084 pts/0    Ss   12:00   0:00 -bash
  davidq    1235  0.0  0.1  10060  1008 pts/0    R+   12:01   0:00 ps aux

Description:

  • USER: The user who owns the process.
  • %CPU: Percentage of CPU usage.
  • %MEM: Percentage of memory usage.
  • VSZ: Virtual memory size of the process.
  • RSS: Resident Set Size, the physical memory used by the process.
  • STAT: Process state (e.g., running, sleeping, etc.).
  • START: Time when the process started.
  • TIME: Total CPU time used by the process.
  • COMMAND: Command used to start the process.
  • ps -ef: Displays a full-format listing of all processes. Sample Command and Output:
  $ ps -ef
  UID        PID  PPID  C STIME TTY          TIME CMD
  root         1     0  0 Aug09 ?        00:00:01 /sbin/init
  davidq    1234     1  0 12:00 pts/0    00:00:00 -bash
  davidq    1235  1234  0 12:01 pts/0    00:00:00 ps -ef

Description:

  • UID: User ID of the process owner.
  • PPID: Parent Process ID, indicating the process that spawned this process.
  • C: CPU utilization percentage.
  • STIME: Start time of the process.
  • ps -u username: Displays processes owned by a specific user. Sample Command and Output:
  $ ps -u davidq
  PID TTY          TIME CMD
 1234 pts/0    00:00:00 bash
 1235 pts/0    00:00:00 ps

Description:

  • Lists only the processes that are owned by the specified user (davidq in this case).
  • ps -p PID: Displays information about a specific process by its PID. Sample Command and Output:
  $ ps -p 1234
  PID TTY          TIME CMD
 1234 pts/0    00:00:00 bash

Description:

  • Filters the output to show only the process with the specified PID (1234).

Note: The ps command is a vital tool for monitoring and managing processes on a Linux system, allowing users to gain insights into what processes are running, their resource usage, and their status. It is often used in conjunction with other tools like grep, awk, or sort for more advanced process management and automation tasks.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.