> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# ps -ef Command Examples
- URL: https://linuxhandbook.com/ps-ef-examples/
- Published: 2023-11-04T06:10:16.000Z
- Updated: 2023-11-14T09:39:57.000Z
- Description: The ps command coupled with the ef flag gives you all the processes running on the system along with addition details.
- Author: Sagar Sharma
- Tags: Quick Tip

The ps command in Linux is used to get a report of the current processes of your system.

But when you pair the ps command with the `-ef` flag, it gives you a detailed and comprehensive overview of all processes running on your system.

So in this tutorial, first, I will explain the output of the `ps -ef` command and then will add more examples to get more out of the `ps -ef` command.

## Meaning of ps -ef command in Linux 

Let's start with the execution of the `ps -ef` command.

When you execute the ps command without any additional flags, it will list down the active processes attached to the current terminal session:

```
ps
```

![Use ps command in Linux](https://linuxhandbook.com/content/images/2023/11/Use-ps-command-in-Linux.png)

As you can see, it listed two processes that were attached to the terminal. But that's not what we always want as users may have multiple terminals opened with different ongoing processes. 

And here's where the use of the `-ef` flag comes in!

Before I jump to the explanation part of the `-ef` flag, let's have a look at what output you'd get when you execute the ps command with the `-ef` flag:

```
ps -ef
```

![Use the ps -ef command in Linux](https://linuxhandbook.com/content/images/2023/11/Use-the-ps--ef-command-in-Linux.png)

Even if you don't know the meaning of output (which I'm about to explain in a minute), you can tell that it gives you more data than the `ps` command without any flags. Right?

Now, let's have a look at the meaning of the `-ef` flag.

- `-e`: Selects all the processes of the system
- `-f`: Gives you additional details for the selected processes like UID, PID, PPID, etc.

In simple terms, when you use the `ps -ef` command, it will list every ongoing process of the system and will give you additional details for every process.

Now, let's break down the output you get when you use the `ps -ef` command.

- `UID`: Shows the user ID of the process owner.
- `PID`: Indicates the process ID of that process.
- `PPID`: Gets the parent process ID. This means it will show the process ID of the parent process.
- `C`: CPU utilization by that process.
- `STIME`: Time when the process was started.
- `TTY`: Terminal associated with that process and if it is not associated with a terminal then it will indicate `?` or `-` mark.
- `TIME`: Tells you for how long that process utilized your CPU.
- `CMD`: Shows the command that initiated that process.

Now, let's have a look at different examples of using the `ps -ef` command.

## How to use the ps -ef command 

In this section, I will walk you through multiple practical ways to use the ps -ef command by which you can get the most out of it.

### 1\. Display a process tree 

When you pair the `--forest` flag with the `ps -ef` command, it can be used to [display process tree in Linux](https://linuxhandbook.com/show-process-tree/):

```
ps -ef --forest
```

![Display process tree using the ps -ef command in Linux](https://linuxhandbook.com/content/images/2023/11/Display-process-tree-using-the-ps--ef-command-in-Linux-1.png)

### 2\. Find the ongoing process 

When you execute the `ps -ef` command, it shows you a bunch of processes and you may want to scroll multiple times to find that suspicious process causing issues.

In that case, you can [use the grep command to sort output](https://linuxhandbook.com/grep-command-cheatsheet/):

```
ps -ef | grep "process_name"
```

For example, if I want to look for if there's any process related to nano, then I will be using the following command:

```
ps -ef | grep "nano"
```

![Find process from the ps -ef output using the grep command](https://linuxhandbook.com/content/images/2023/11/Find-process-from-the-ps--ef-output-using-the-grep-command.png)

### 3\. Show processes with the full command 

When you use the `ps -ef` command, it will cut the execution command (shown in the `CMD` column) if not enough space is available.

To tackle this situation, you can use the `ww` option as shown:

```
ps -efww
```

![Show execution command without truncation with the ps -ef command](https://linuxhandbook.com/content/images/2023/11/Show-execution-command-without-truncation-with-the-ps--ef-command.png)

### 4\. Sort processes based on memory usage 

To sort the shown processes based on the memory usage, you can use the `--sort=-%mem` flag as shown:

```
ps -ef --sort=-%mem
```

![sort processes based on memory utilization in the ps -ef command](https://linuxhandbook.com/content/images/2023/11/sort-processes-based-on-memory-utilization-in-the-ps--ef-commadn.png)

### 5\. Sort processes based on CPU utilization 

To sort the processes based on CPU utilization, you can use the `--sort=-%cpu` flag as shown here:

```
ps -ef --sort=-%cpu
```

![sort processes based on CPU utilization in the ps -ef commadn](https://linuxhandbook.com/content/images/2023/11/sort-processes-based-on-CPU-utilization-in-the-ps--ef-commadn.png)

## Bonus: Show processes of a specific user 

There's a reason why I'm adding this in the bonus section.

To show the processes of a specific user, you need to use the `-U` flag which was not giving me appropriate results when paired with the `-ef` flag.

But still, it is one of the best implementations of the ps command which is why I'm including this in the bonus section.

To show the processes of a specific user, use the `-U` flag in the following manner:

```
ps -U user_name
```

For example, here, I listed processes that belonged to the user `sagar`:

```
ps -U sagar
```

![List processes belonged to a specific user using the ps command](https://linuxhandbook.com/content/images/2023/11/List-processes-belonged-to-a-specific-user-using-the-ps-command.png)

## Do more with the ps command 

There are multiple ways to use the ps command and to explain [how to get the most out of the ps command](https://linuxhandbook.com/ps-command/), we made a detailed tutorial for that topic:

[Essential Examples of the ps Command in LinuxThe ps command in Linux is used for getting information about running processes. Here are some useful examples of the complicated and extensive ps command.![](https://linuxhandbook.com/content/images/size/w256h256/2021/08/Linux-Handbook-New-Logo.png)Linux HandbookAbhishek Prakash![](https://linuxhandbook.com/content/images/2020/06/PS-Command-in-Linux.png)](https://linuxhandbook.com/ps-command/)

I hope you will find this guide helpful.