What is ps -ef Command and How to Use it in Linux


The ps -ef command is a commonly used Linux command that provides a detailed list of all currently running processes in the system. We will examine how this command functions in this post and how to use it to manage and monitor processes on a Linux system. For illustration I will use Linux Mint 21 operating system but you can use any of the Linux distros.

What is ps -ef command in Linux?

By default, the ps command only displays processes that are running in the current terminal window. However, with the addition of the -ef option, the command displays all processes in the system, regardless of which terminal session they were started in.

What does ps -ef command do?

The ps -ef returns a list of all currently running processes on the system, along with information about each one, including its process ID (PID), parent process ID (PPID), initiating user, CPU, and memory consumption, and command line though which it is initiated. Here is an output of the ps -ef command:

ps -ef

  • The First column displays the user ID (UID) of the user who started the process.
  • The Second column displays the PID of the process, which is a unique identifier assigned to every process by the system.
  • The Third column displays the PPID, which is the PID of the parent process that started the current process.
  • The fourth column displays the amount of CPU time used by the process, expressed as a percentage.
  • The fifth column displays the time at which the process was started.
  • The sixth column is the TTY column that displays a character string that represents the TTY associated with each process. If a process is running in the background and is not connected to a TTY, the TTY column displays a question mark (?).
  • The seventh column displays the command line used to start the process.

How to use ps -ef command in Linux

There are numerous ways to manage and observe processes in a Linux system using the ps -ef command. For example, it can be used to identify processes that are consuming a large amount of CPU or memory resources, or to locate processes that are causing performance issues on the system.

The ps command can also be combined with other Linux commands like kill or renice to end or change the priority of particular process. For example, the following command can be used to terminate a process with a given PID:

kill 2830

Conclusion

The ps -ef command is a powerful tool for monitoring and managing processes in a Linux system. By providing detailed information about all currently running processes, it can be used to identify and troubleshoot performance issues, and to terminate or adjust the priority of specific processes as needed.

 

Print Friendly, PDF & Email
Categories