Skip to content

Linux ps command

The Linux ps command is a powerful tool used to list information about processes running on a system. It allows users to view detailed information such as process ID, CPU and memory usage, parent process ID, and more. With various options available, users can customize the output to meet their specific requirements. By understanding how to use the ps command effectively, users can easily monitor and manage processes on their Linux system.

ps Syntax:

Terminal window
ps [options]

Options:

OptionDescription
-aDisplay information about other users
-eDisplay information about all processes, not just those associated with the current user
-fFull-format listing
-lLong-format listing
-uDisplay information about processes associated with a specific user

Parameters:

ParameterDescription
PIDDisplay information about a specific process by its PID
TTYDisplay information about processes associated with a specific TTY

ps Usage:

Display All Processes

Terminal window
ps

Displays information about all current processes running on the system.

Display Processes of a Specific User

Terminal window
ps -u username

Displays processes associated with a specific user (replace “username” with the actual username).

Display Processes in a Tree Hierarchy

Terminal window
ps -e --forest

Displays processes in a tree hierarchy to show parent-child relationships.

Display Detailed Process Information

Terminal window
ps -aux

Displays detailed information about all processes running on the system, including those owned by other users.

Common Questions on ps Usage:

How do I use ps in Linux?

To use the ps command in Linux, execute the following command:

Terminal window
ps

What option displays all processes with detailed information using ps?

To display all processes with detailed information, use the following command:

Terminal window
ps -ef

How can I filter processes by a specific user using ps in Linux?

To filter processes by a specific user, use the following command:

Terminal window
ps -u username

How do I display a hierarchical view of processes using ps in Linux?

To display a hierarchical view of processes, use the following command:

Terminal window
ps -ejH

How can I show memory usage information of processes with ps in Linux?

To show memory usage information of processes, use the following command:

Terminal window
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem

How do I continuously monitor processes using ps in Linux?

To continuously monitor processes, use the following command:

Terminal window
watch -n 1 'ps aux'

How can I display the total resource usage of all processes using ps in Linux?

To display the total resource usage of all processes, use the following command:

Terminal window
ps -aux --sort=-%mem | head

Applications of the ps command

  • Monitoring system processes
  • Displaying information about running processes
  • Viewing detailed information about specific processes
  • Tracking resource usage of processes
  • Investigating CPU and memory usage
  • Identifying which processes are consuming system resources
  • Troubleshooting performance issues
  • Checking process status and owner
  • Killing or terminating specific processes