Skip to main content
Quick Tip

ps -ef Command Examples

The ps command coupled with the ef flag gives you all the processes running on the system along with addition details.

Sagar Sharma

Warp Terminal

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

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

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:

ps -ef --forest

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:

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"

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

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

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

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

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, we made a detailed tutorial for that topic:

Essential Examples of the ps Command in Linux
The ps command in Linux is used for getting information about running processes. Here are some useful examples of the complicated and extensive ps command.

I hope you will find this guide helpful.

Sagar Sharma