Skip to content

pstree Linux Command Guide

The pstree command in Linux allows users to view a structured tree diagram of all running processes on the system. By displaying parent-child relationships, pstree provides a clear overview of the process hierarchy, making it easier to understand how different processes are related and organized. This can be particularly useful for troubleshooting, monitoring system performance, and managing processes effectively.

pstree Syntax:

Terminal window
pstree [option] [pid]

Options:

OptionDescription
-aShow command line arguments
-cShow the command name
-hHighlight the current process
-lUse long format
-nSort by PID
-pShow PIDs
-uDisplay UID
-vDisplay PPID

Parameters:

ParameterDescription
pidSpecify the process ID to start

pstree Command Samples:

Display the process tree

Terminal window
pstree

This command displays the current process tree in a hierarchical format.

Display the process tree with a specific PID

Terminal window
pstree -p 1234

This command displays the process tree starting from the process with PID 1234.

Display the process tree with additional information

Terminal window
pstree -a

This command displays the process tree with additional information such as the process’s full command line.

Display the process tree recursively

Terminal window
pstree -h

This command displays the process tree in a format suitable for viewing on the terminal.

Display the process tree with ASCII characters

Terminal window
pstree -A

This command displays the process tree using ASCII characters for better readability.

Display the process tree along with CPU usage

Terminal window
pstree -c

This command shows the process tree along with CPU usage information.

Display the process tree with user/group details

Terminal window
pstree -ug

This command displays the process tree along with user and group details for each process.

How do I use pstree in Linux?

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

Terminal window
pstree

What is the purpose of the pstree command?

The pstree command displays running processes as a tree. It shows the relationship between processes, with the parent-child hierarchy represented visually.

How can I display the process tree of a specific process ID with pstree?

You can display the process tree for a specific process ID by using the following command:

Terminal window
pstree -p <PID>

Can I display the pstree with full path names of processes?

Yes, you can display the pstree with full path names of processes by using the following command:

Terminal window
pstree -a

How can I show the pstree with the user that owns each process?

To show the pstree with the user that owns each process, you can use the following command:

Terminal window
pstree -u

Is there a way to display the pstree with the command line arguments of processes?

You can display the pstree with the command line arguments of processes by using the following command:

Terminal window
pstree -c

Applications of the pstree command

  • Displaying a tree of processes
  • Highlighting the relationship between processes
  • Providing a visual representation of the process hierarchy
  • Identifying parent and child processes
  • Monitoring process relationships