In Linux, the “ps” command is a command-line utility for viewing information about the running processes. The “ef” option stands for “full” and is used to display the command line arguments passed to the process, in addition to the other information normally shown by the “ps” command.
The objective of this guide is to explain the βps -efβ command in Linux with the help of suitable examples.
Let’s start with the βps-efβ command.
How Does the βps-efβ Command Work in Linux?
The βps -efβ command displays a list of processes, with each process occupying one line. Let’s see the basic working of the βps -efβ command by executing the script:
$ ps -ef
The output shows a list of processes. The columns in the output show the following information:
- UID: the user ID of the user who owns the process
- PID: the process ID of the process
- PPID: the process ID of the parent process
- C: the CPU utilization of the process, as a percentage
- STIME: the time at which the process was started
- TTY: the terminal associated with the process
- TIME: the CPU time used by the process
- CMD: the command that was used to start the process, including any command-line arguments passed to the process
Here are some examples of using the “ps ef” command in Linux:
Example 1: Display All Processes Running on the System
To display the running process in the current system, the “ps ef” command is utilized as below:
$ ps ef
The output shows the list of processes with the command line arguments passed to the processes.
Example 2: Display All Processes Belonging to a Specific User
To display all processes of the particular user, specify the β-uβ option that represents the username such as βitslinuxfossβ:
$ ps ef -u itslinuxfoss
The output shows the list of the all running processes of βitslinuxfossβ user in the system.
Example 3: Display Processes With a Specific PID
We can display the specific process using the process id. For this, specify the β2542β id of the βfirefoxβ process with the βpβ option:
$ ps ef -p 2542
The output shows the details of a particular process based on the process id.
Example 4: Display Processes to a Specific Process Group
To display the processes associated with the same group, use the β-gβ option with the process id:
$ ps ef -g 1250
The output returns the list of multiple processes with the same group.
Example 5: Display Processes With a Specific Terminal
To display the list of running processes with the specific terminal, utilize the βtβ option as below:
$ ps ef -t tty2
Example 6: Display Processes Specific Session
For displaying processes that are associated with a particular session, execute the β-sβ option as below:
$ ps ef -s 1250
The output returns the processes of a specific session.
Example 7: Display All Processes Except a Specific UID
To display all processes except those with a specific UID, use the β-Uβ option by specifying the username:
$ ps ef -U itslinuxfoss
The output displays all processes except βitslinuxfossβ.
Example 8: Display Processes Sorted by Memory Usage
To visualize the processes sorted by memory usage, use the βpmemβ utility with the βoβ option:
$ ps ef -o pmem
The output returns the processes that are sorted by memory usage.
Example 9: Display Processes by Start Timing
To display processes sorted by start time, use the βlstartβ utility with the β-oβ option as below:
$ ps ef -o lstart
The output returns the sorted list of processes that are recently started.
That is all from the βps -efβ command in Linux.
Conclusion
Linux offers the βps-efβ command that lists the running processes with the command line arguments passed to the process. Additionally, users can display all processes belonging to a specific user, specific PID, process group, specific session, sorted by memory usage, etc. This guide has explained the βps-efβ command with possible examples.