Oct 19, 2023 4 min read

How to Use ps -ef Command on Linux?

Use ps -ef Command in Linux with our step-by-step tutorial. The `ps -ef` command is a Linux tool that displays process details.

Use ps -ef Command on Linux
Table of Contents

Introduction

Before we begin talking about how to use ps -ef Command on Linux, let's briefly understand – What is ps -ef?

The "ps" command is a command-line tool for Linux that displays details about the currently active processes. In addition to the usual details typically displayed by the "ps" command, the "ef" option, which stands for "full," is used to display the command line arguments supplied to the process.

In this tutorial, you will use ps -ef Command on Linux. We will also address a few FAQs on how to use ps -ef Command on Linux.

How Does the “ps-ef” Command Work in Linux?

Each process has its own line in the list of processes that the "ps -ef" command shows. By running the script, let's examine the "ps -ef" command's fundamental operation:

ps -ef

An output of processes is displayed. The following details are displayed in the output's columns:

  • UID: The user ID for the person who is the process owner.
  • PID: This stands for the process ID.
  • PPID: The parent process's process ID.
  • C: The percentage of the process's CPU usage.
  • STIME: the moment when the procedure began.
  • TTY: The process-related terminal.
  • TIME: The amount of CPU time the process used.
  • CMD: The command that was used to launch the process, together with any command-line arguments supplied to the process.

Here are some instances of how to use the Linux "ps ef" command:

Example 1: Show All Processes Running on the System

The "ps ef" command is used as follows to show the active processes in the present system:

ps ef

The list of processes with the command line arguments supplied to the processes is displayed in the output.

Example 2: Show All Processes Belonging to a Specific User

When displaying all processes for a certain user, use the "-u" option to indicate the user's username, such as "vegastack":

ps ef -u vegastack

The output displays a list of every process that the "vegastack" user has opened on the system.

Example 3: Show Processes With a Specific PID

The process id allows us to display the particular process. To do this, use the "p" option and the "firefox" process's "2542" id:

ps ef -p 2542

Based on the process id, the output displays specific process data.

Example 4: Show Processes to a Specific Process Group

Use the "-g" option with the process id to show the processes connected to the same group:

ps ef -g 1250

The output shows a list of all processes belonging to the same group.

Example 5: Show Processes With a Specific Terminal

Use the "t" argument as shown below to display the list of active processes with the specified terminal:

ps ef -t tty2

Example 6: Show Processes Specific Session

Use the "-s" option to display processes connected to a specific session, as shown below:

ps ef -s 1250

The output displays the processes for a particular session.

Example 7: Show All Processes Except a Specific UID

Use the "-U" option and the username to see all processes, excluding those with a particular UID:

ps ef -U vegastack

All processes except "vegastack" are shown in the output.

Example 8: Show Processes Sorted by Memory Usage

Utilize the "pmem" utility and the "o" option to see the processes sorted by memory usage:

ps ef -o pmem

The output brings back the processes in order of memory use.

Example 9: Show Processes by Start Timing

Use the "lstart" utility with the "-o" option as follows to view processes sorted by start time:

ps ef -o lstart

The output provides a sorted list of recently started processes.

That is everything from the Linux "ps -ef" command.

FAQs to Use ps -ef Command on Linux

What information does the ps -ef command provide? 

The ps -ef command provides information such as process IDs, parent process IDs, user ownership, CPU and memory usage, and the command associated with each process.

Can I customize the output of the ps -ef command?

Yes, you can use various options and filters with the ps -ef command to customize the output. For example, you can use -o option to specify the columns you want to display.

How can I sort the output of the ps -ef command? 

You can use the --sort option with ps -ef to sort the output based on different criteria, such as CPU usage, memory usage, process ID, or start time.

Can I filter the output of the ps -ef command to show specific processes? 

Yes, you can use the grep command in combination with ps -ef to filter and display only the processes you are interested in, based on specific keywords or criteria.

Does the ps -ef command show all processes, including those of other users? 

By default, the ps -ef command shows all processes on the system, regardless of the user. However, if you are not running it with root privileges, you may only see your own processes.

How can I interpret the status codes displayed by the ps -ef command? 

The status codes displayed by ps -ef indicate the current state of a process. Common codes include "R" for running, "S" for sleeping, "Z" for zombie processes, and "T" for stopped processes.

Can I use ps -ef to view the complete command associated with each process? 

Yes, the ps -ef command truncates long commands by default. However, you can use the -w option to display the complete command associated with each process.

Conclusion

With the command line arguments supplied to the process, Linux's "ps -ef" command displays a list of all currently active processes. Users can also view all processes associated with a certain user, PID, process group, session, organized by memory usage, etc. This tutorial has described the "ps -ef" command with examples.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.