ps Command: Tutorial & Examples

Display information about running processes

The ps command is used to display information about the currently running processes on a Linux system. To use it, you can simply type ps followed by any number of options that modify the output.

Here are some common options you can use with ps:

  • -a: Display all processes that are owned by the current user.
  • -x: Display processes that are not associated with a terminal.
  • -u: Display the process owner and the process command name.
  • -e: Display all processes.

For example, to display all processes that are owned by the current user, you could use the following command:

ps -a

The output of ps will contain several columns of information about each process. Here is a brief explanation of each column:

  • PID: The process ID, a unique number assigned to each process.
  • TTY: The terminal associated with the process.
  • TIME: The amount of CPU time used by the process.
  • CMD: The command that was used to start the process.

For example, the output of ps -u might look something like this:

PID TTY          TIME CMD
123 ?        00:00:01 bash
456 ?        00:00:00 gedit
789 ?        00:00:00 firefox

This shows that there are three processes running: a bash shell, the gedit text editor, and the firefox web browser. The PID column shows the process ID for each process, the TTY column shows the terminal associated with the process, and the TIME column shows the amount of CPU time used by the process.

You can also use the ps command with the grep command to search for specific processes. For example, to find all processes with the name "firefox", you could use the following command:

ps -e | grep firefox

This will display all processes, and grep will filter the output to only show lines that contain the string "firefox".

Except where otherwise noted, content on this site is licensed under a CC BY-SA 4.0 license CC BY SA