Linux commands: ps
A comprehensive guide to using the ps command in Linux to list and manage running processes.
At any given time, your computer is running numerous processes. To inspect and manage these processes, the ps command comes in handy. It provides a list of the processes currently running in the system.

The displayed list represents the user-initiated processes in the current session. For example, you may see multiple instances of the fish shell, mainly opened by VS Code within the editor, and an instance of Hugo running the development preview of a site. However, to list all processes, we need to include specific options when using ps.
One of the most commonly used options is ax: ps ax.

The a option lists processes from all users, not just the current one, while x shows processes not linked to any terminal (i.e., those not initiated by users through a terminal).
By default, the output may truncate long command names. To display the full command, use ps axww:

Note that w needs to be specified twice to apply the line-wrapping setting. This avoids command truncation in the output.
To search for specific processes, you can combine ps with the grep command using a pipe:
1 | ps axww | grep "VS Code" |

The columns returned by ps represent essential information about the processes.
- The first column is the
PID, which stands for Process ID. You can use this ID to reference the process in other commands, such as killing it. - The
TTcolumn displays the terminal ID used by the process. - The
STATcolumn represents the state of the process, where each letter indicates a specific state (e.g.,Rfor a runnable process,Tfor a stopped process, andZfor a dead process). - Additional letters in the
STATcolumn provide further technical information about the process. - The
+symbol signifies that the process is in the foreground in its terminal, whilesindicates that the process is a session leader.
The TIME column indicates how long the process has been running.
It’s important to note that the ps command works on Linux, macOS, WSL, and any UNIX environment.
tags: [“Linux commands”, “ps”, “processes”, “terminal”, “grep”]