ptree - Man Page

print process trees

Synopsis

ptree [-ag] [pid|user]...

Description

Print process trees containing the specified PIDs or users, with child processes indented from their respective parent processes. An argument of all digits is taken to be a process ID; otherwise it is assumed to be a user login name. The default is all processes.

Options

-a,  --all

All. Print all processes, including children of process ID 0.

-g,  --graph

Use line drawing characters. If the current locale is a UTF-8 locale, the UTF-8 line drawing characters are used, otherwise ASCII line drawing characters are used.

Operands

pid

Process ID. A /proc/pid path may also be used, allowing shell expansions like /proc/* to target all processes on the system.

user

User login name.

Examples

Example 1 Using ptree The following example prints the process tree (including children of process 0) for processes which match the command name ssh:

  $ ptree -a `pgrep ssh`
          1  /sbin/init
            100909  /usr/bin/sshd
              569150  /usr/bin/sshd
                569157  /usr/bin/sshd
                  569159  -bash
                    569171  bash
                      569173  /usr/bin/bash
                        569193  bash

Example 2 The following example prints the process tree (including children of process 0) for processes which match the command name ssh with ASCII line drawing characters:

  $ ptree -ag `pgrep ssh`
          1  /sbin/init
          `-100909  /usr/bin/sshd
            `-569150  /usr/bin/sshd
              `-569157  /usr/bin/sshd
                `-569159  -bash
                  `-569171  bash
                    `-569173  /usr/bin/bash
                      `-569193  bash

Exit Status

0 on success, non-zero if an error occurs (such as no such process, permission denied, or invalid option).

Files

/proc/pid/*

Process information and control files.

See Also

pargs(1), pgrep(1), ps(1), proc(5)

Info

March 2026 ptree 0.2.18