> For the complete documentation index, see [llms.txt](https://linux-tutorial-cli.gitbook.io/linux-cli-tutorial/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://linux-tutorial-cli.gitbook.io/linux-cli-tutorial/txt-files/ps.md).

# ps

## ps

The `ps` command in Linux is used to list currently running processes. It provides a snapshot of active processes on the system, showing information such as process IDs (PIDs), CPU and memory usage, command names, and more. Here’s a detailed explanation of how to use `ps` and what information it provides:

#### Usage of `ps`

**Basic Usage**

To use `ps`, open a terminal and type:

```bash
ps
```

By default, `ps` displays a list of processes associated with the current terminal session.

**Options and Output**

`ps` provides output with different columns representing various process attributes:

1. **Default Columns**

   * `PID`: Process ID.
   * `TTY`: Terminal associated with the process.
   * `TIME`: CPU time consumed by the process.
   * `CMD`: Command name or command line used to start the process.

   Example output:

   ```
   PID TTY          TIME CMD
   1234 pts/0    00:00:01 bash
   5678 pts/0    00:00:00 ps
   ```
2. **Options**

   * `-e`: Display information about all processes.
   * `-f`: Full-format listing showing more details such as UID, PPID, C (CPU utilization), STIME (start time), etc.
   * `-l`: Long format listing showing additional information like process flags, nice value, and more.
   * `-u`: Display processes belonging to a specific user.

   Example:

   ```bash
   ps -ef       # Display all processes in full format
   ps aux       # Display all processes with user-oriented format
   ps -u user   # Display processes for a specific user
   ```
3. **Process States**

   * `R`: Running or runnable (on run queue).
   * `S`: Interruptible sleep (waiting for an event to complete).
   * `D`: Uninterruptible sleep (usually waiting for disk IO).
   * `Z`: Zombie state (process terminated, but its entry still remains in the process table).

   Example:

   ```bash
   ps -ef | grep firefox     # Display processes matching a specific command
   ```

#### Use Cases

* **Process Management:** `ps` helps in listing processes, identifying their attributes, and managing them (killing, prioritizing, etc.).
* **Performance Monitoring:** Useful for monitoring CPU and memory usage by processes.
* **Troubleshooting:** Helps diagnose issues related to excessive resource consumption or process contention.

#### Conclusion

`ps` is a fundamental command-line tool for listing and managing processes on Linux systems. It provides essential information about running processes, their resource usage, and relationships. By understanding its output and options, administrators and users can effectively monitor system activity, diagnose issues, and optimize system performance.

## help

```
Usage:
 ps [options]

 Try 'ps --help <simple|list|output|threads|misc|all>'
  or 'ps --help <s|l|o|t|m|a>'
 for additional help text.

For more details see ps(1).
```
