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