]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/sockstat/sockstat.1
OpenSSL: Merge OpenSSL 1.1.1p
[FreeBSD/FreeBSD.git] / usr.bin / sockstat / sockstat.1
1 .\"-
2 .\" Copyright (c) 1999 Dag-Erling Coïdan Smørgrav
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer
10 .\"    in this position and unchanged.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\" 3. The name of the author may not be used to endorse or promote products
15 .\"    derived from this software without specific prior written permission.
16 .\"
17 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 .\"
28 .\" $FreeBSD$
29 .\"
30 .Dd February 2, 2022
31 .Dt SOCKSTAT 1
32 .Os
33 .Sh NAME
34 .Nm sockstat
35 .Nd list open sockets
36 .Sh SYNOPSIS
37 .Nm
38 .Op Fl 46CciLlnqSsUuvw
39 .Op Fl j Ar jail
40 .Op Fl p Ar ports
41 .Op Fl P Ar protocols
42 .Sh DESCRIPTION
43 The
44 .Nm
45 command lists open Internet or
46 .Ux
47 domain sockets.
48 .Pp
49 The following options are available:
50 .Bl -tag -width Fl
51 .It Fl 4
52 Show
53 .Dv AF_INET
54 (IPv4) sockets.
55 .It Fl 6
56 Show
57 .Dv AF_INET6
58 (IPv6) sockets.
59 .It Fl C
60 Display the congestion control module, if applicable.
61 This is currently only implemented for TCP.
62 .It Fl c
63 Show connected sockets.
64 .It Fl i
65 Display the
66 .Dv inp_gencnt .
67 .It Fl j Ar jail
68 Show only sockets belonging to the specified jail ID or name.
69 .It Fl L
70 Only show Internet sockets if the local and foreign addresses are not
71 in the loopback network prefix
72 .Li 127.0.0.0/8 ,
73 or do not contain the IPv6 loopback address
74 .Li ::1 .
75 .It Fl l
76 Show listening sockets.
77 .It Fl n
78 Do not resolve numeric UIDs to user names.
79 .It Fl p Ar ports
80 Only show Internet sockets if the local or foreign port number
81 is on the specified list.
82 The
83 .Ar ports
84 argument is a comma-separated list of port numbers and ranges
85 specified as first and last port separated by a dash.
86 .It Fl P Ar protocols
87 Only show sockets of the specified
88 .Ar protocols .
89 The
90 .Ar protocols
91 argument is a comma-separated list of protocol names,
92 as they are defined in
93 .Xr protocols 5 .
94 .It Fl q
95 Quiet mode, do not print the header line.
96 .It Fl S
97 Display the protocol stack, if applicable.
98 This is currently only implemented for TCP.
99 .It Fl s
100 Display the protocol state, if applicable.
101 This is currently only implemented for SCTP and TCP.
102 .It Fl U
103 Display the remote UDP encapsulation port number, if applicable.
104 This is currently only implemented for SCTP and TCP.
105 .It Fl u
106 Show
107 .Dv AF_LOCAL
108 .Pq Ux
109 sockets.
110 .It Fl v
111 Verbose mode.
112 .It Fl w
113 Use wider field size for displaying addresses.
114 .El
115 .Pp
116 If neither
117 .Fl 4 , 6
118 or
119 .Fl u
120 is specified,
121 .Nm
122 will list sockets in all three domains.
123 .Pp
124 If neither
125 .Fl c
126 or
127 .Fl l
128 is specified,
129 .Nm
130 will list both listening and connected sockets.
131 .Pp
132 The information listed for each
133 socket is:
134 .Bl -tag -width "FOREIGN ADDRESS"
135 .It Li USER
136 The user who owns the socket.
137 .It Li COMMAND
138 The command which holds the socket.
139 .It Li PID
140 The process ID of the command which holds the socket.
141 .It Li FD
142 The file descriptor number of the socket.
143 .It Li PROTO
144 The transport protocol associated with the socket for Internet
145 sockets, or the type of socket
146 .Pq stream, datagram, or seqpacket
147 for
148 .Ux
149 sockets.
150 .It Li LOCAL ADDRESS
151 For Internet sockets, this is the address the local end of the socket
152 is bound to (see
153 .Xr getsockname 2 ) .
154 For bound
155 .Ux
156 sockets, it is the socket's filename.
157 For other
158 .Ux
159 sockets, it is a right arrow followed by the endpoint's filename, or
160 .Dq Li ??
161 if the endpoint could not be determined.
162 .It Li FOREIGN ADDRESS
163 (Internet sockets only)
164 The address the foreign end of the socket is bound to (see
165 .Xr getpeername 2 ) .
166 .It Li ID
167 The inp_gencnt if
168 .Fl i
169 is specified (only for TCP or UDP).
170 .It Li ENCAPS
171 The remote UDP encapsulation port number if
172 .Fl U
173 is specified (only for SCTP or TCP).
174 .It Li PATH STATE
175 The path state if
176 .Fl s
177 is specified (only for SCTP).
178 .It Li CONN STATE
179 The connection state if
180 .Fl s
181 is specified (only for SCTP or TCP).
182 .It Li STACK
183 The protocol stack if
184 .Fl S
185 is specified (only for TCP).
186 .It Li CC
187 The congestion control if
188 .Fl C
189 is specified (only for TCP).
190 .El
191 .Pp
192 If a socket is associated with more than one file descriptor,
193 it is shown multiple times.
194 If a socket is not associated with any file descriptor,
195 the first four columns have no meaning.
196 .Sh EXAMPLES
197 Show information for IPv4 sockets listening on port 22 using protocol
198 TCP:
199 .Bd -literal -offset indent
200 $ sockstat -4 -l -P tcp -p 22
201 .Ed
202 .Pp
203 Show information for sockets using either TCP or UDP, if neither, the local nor
204 the foreign addresses are in the loopback network:
205 .Bd -literal -offset indent
206 $ sockstat -L -P tcp,udp
207 .Ed
208 .Pp
209 Show TCP IPv6 sockets which are listening and connected (default):
210 .Bd -literal -offset indent
211 $ sockstat -6 -P tcp
212 .Ed
213 .Sh SEE ALSO
214 .Xr fstat 1 ,
215 .Xr netstat 1 ,
216 .Xr procstat 1 ,
217 .Xr inet 4 ,
218 .Xr inet6 4 ,
219 .Xr protocols 5
220 .Sh HISTORY
221 The
222 .Nm
223 command appeared in
224 .Fx 3.1 .
225 .Sh AUTHORS
226 The
227 .Nm
228 command and this manual page were written by
229 .An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .