xref: /illumos-gate/usr/src/man/man1/ptree.1 (revision b645077bdf2e638b9017226e178e6b84162dd6a8)
1.\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
2.\" Copyright 2019, Joyent, Inc.
3.\" Copyright 2024 Jason King
4.\"
5.\" The contents of this file are subject to the terms of the
6.\" Common Development and Distribution License (the "License").
7.\" You may not use this file except in compliance with the License.
8.\"
9.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10.\" or http://www.opensolaris.org/os/licensing.
11.\" See the License for the specific language governing permissions
12.\" and limitations under the License.
13.\"
14.\" When distributing Covered Code, include this CDDL HEADER in each
15.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16.\" If applicable, add the following below this CDDL HEADER, with the
17.\" fields enclosed by brackets "[]" replaced with your own identifying
18.\" information: Portions Copyright [yyyy] [name of copyright owner]
19.\"
20.Dd January 9, 2025
21.Dt PTREE 1
22.Os
23.Sh NAME
24.Nm ptree
25.Nd print process trees
26.Sh SYNOPSIS
27.Nm
28.Op Fl a
29.Op Fl c
30.Op Fl g
31.Op Fl w
32.Op Fl s Ar svc
33.Op Fl z Ar zone
34.Oo Ar pid | Ar user Oc Ns ...
35.Sh DESCRIPTION
36The
37.Nm
38utility prints the process trees containing the specified
39.Ar pid Ns s
40or
41.Ar user Ns s ,
42with child processes indented from their respective parent processes.
43An argument of all digits is taken to be a process-ID,
44otherwise it is assumed to be a user login name.
45The default is all processes.
46.Sh OPTIONS
47The following options are supported:
48.Bl -tag -width "-z zone"
49.It Fl a
50All.
51Print all processes, including children of process 0.
52.It Fl c
53Contracts.
54Print process contract memberships and their associated SMF FMRIs, in addition
55to parent-child relationships.
56See
57.Xr process 5 .
58This option implies the
59.Fl a
60option.
61.It Fl g
62Use line drawing characters.
63If the current locale is a UTF-8 locale, the UTF-8 line drawing characters are
64used, otherwise ASCII line drawing characters are used.
65.It Fl s Ar svc
66Print only processes with an SMF service FMRI matching the argument.
67The FMRI may be in truncated form
68.Po
69such as
70.Ql console-login
71.Pc .
72This includes child processes even if they are not members of the service
73contract.
74See
75.Xr process 5 .
76.It Fl w
77Allow output lines to wrap.
78Normally output lines are truncated to the current width of the terminal window.
79.It Fl z Ar zone
80Zones.
81Print only processes in the specified
82.Ar zone .
83Each zone
84.Sy ID
85can be specified as either a zone name or a numerical zone
86.Sy ID .
87.Pp
88This option is only useful when executed in the global zone.
89.El
90.Sh OPERANDS
91The following operands are supported:
92.Bl -tag -width "user"
93.It Ar pid
94Process-id or a list of process-ids.
95.Nm
96also accepts
97.Pa /proc/ Ns Em nnn
98as a process-id, so the shell expansion
99.Pa /proc/*
100can be used to specify all processes in the system.
101.It Ar user
102Username or list of usernames.
103Processes whose effective user IDs match those
104given are displayed.
105.El
106.Sh FILES
107.Bl -tag -width Pa
108.It Pa /proc/*
109process files
110.El
111.Sh EXIT STATUS
112.Ex -std
113.Sh EXAMPLES
114.Bl -inset
115.It Sy Example 1
116Using ptree
117.Pp
118The following example prints the process tree (including children of process 0)
119for processes which match the command name
120.Sy ssh :
121.Bd -literal -offset 2n
122$ ptree -a `pgrep ssh`
123        1     /sbin/init
124          100909 /usr/lib/ssh/sshd
125            569150 /usr/lib/ssh/sshd
126              569157 /usr/lib/ssh/sshd
127                569159 -ksh
128                  569171 bash
129                    569173 /bin/ksh
130                      569193 bash
131.Ed
132.It Sy Example 2
133.Pp
134The following example prints the process tree (including children of process 0)
135for processes which match the command name
136.Ql ssh
137with ASCII line drawing characters:
138.Bd -literal -offset 2n
139$ ptree -ag `pgrep ssh`
140        1     /sbin/init
141        `-100909 /usr/lib/ssh/sshd
142          `-569150 /usr/lib/ssh/sshd
143            `-569157 /usr/lib/ssh/sshd
144              `-569159 -ksh
145                `-569171 bash
146                  `-569173 /bin/ksh
147                    `-569193 bash
148.Ed
149.El
150.Sh INTERFACE STABILITY
151Not-an-Interface
152.Sh SEE ALSO
153.Xr pargs 1 ,
154.Xr pgrep 1 ,
155.Xr pkill 1 ,
156.Xr preap 1 ,
157.Xr proc 1 ,
158.Xr ps 1 ,
159.Xr contract 5 ,
160.Xr proc 5 ,
161.Xr process 5 ,
162.Xr attributes 7 ,
163.Xr zones 7
164