xref: /freebsd/usr.bin/sockstat/sockstat.1 (revision 313376588638950ba1e93c403dd8c97bc52fd3a2)
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 May 16, 2012
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 46cLlu
39.Op Fl j Ar jid
40.Op Fl p Ar ports
41.Op Fl P Ar protocols
42.Sh DESCRIPTION
43The
44.Nm
45command lists open Internet or
46.Ux
47domain sockets.
48.Pp
49The following options are available:
50.Bl -tag -width Fl
51.It Fl 4
52Show
53.Dv AF_INET
54(IPv4) sockets.
55.It Fl 6
56Show
57.Dv AF_INET6
58(IPv6) sockets.
59.It Fl c
60Show connected sockets.
61.It Fl j Ar jid
62Show only sockets belonging to the specified jail ID.
63.It Fl L
64Only show Internet sockets if the local or foreign addresses are not
65in the loopback network prefix
66.Li 127.0.0.0/8 ,
67or do not contain the IPv6 loopback address
68.Li ::1 .
69.It Fl l
70Show listening sockets.
71.It Fl p Ar ports
72Only show Internet sockets if either the local or foreign port number
73is on the specified list.
74The
75.Ar ports
76argument is a comma-separated list of port numbers and ranges
77specified as first and last port separated by a dash.
78.It Fl P Ar protocols
79Only show sockets of the specified
80.Ar protocols .
81The
82.Ar protocols
83argument is a comma-separated list of protocol names,
84as they are defined in
85.Xr protocols 5 .
86.It Fl u
87Show
88.Dv AF_LOCAL
89.Pq Ux
90sockets.
91.El
92.Pp
93If neither
94.Fl 4 , 6
95or
96.Fl u
97is specified,
98.Nm
99will list sockets in all three domains.
100.Pp
101If neither
102.Fl c
103or
104.Fl l
105is specified,
106.Nm
107will list both listening and connected sockets.
108.Pp
109The information listed for each
110socket is:
111.Bl -tag -width "FOREIGN ADDRESS"
112.It Li USER
113The user who owns the socket.
114.It Li COMMAND
115The command which holds the socket.
116.It Li PID
117The process ID of the command which holds the socket.
118.It Li FD
119The file descriptor number of the socket.
120.It Li PROTO
121The transport protocol associated with the socket for Internet
122sockets, or the type of socket (stream or datagram) for
123.Ux
124sockets.
125.It Li LOCAL ADDRESS
126For Internet sockets, this is the address the local end of the socket
127is bound to (see
128.Xr getsockname 2 ) .
129For bound
130.Ux
131sockets, it is the socket's filename.
132For other
133.Ux
134sockets, it is a right arrow followed by the endpoint's filename, or
135.Dq Li ??
136if the endpoint could not be determined.
137.It Li FOREIGN ADDRESS
138(Internet sockets only)
139The address the foreign end of the socket is bound to (see
140.Xr getpeername 2 ) .
141.El
142.Pp
143If a socket is associated with more than one file descriptor,
144it is shown multiple times.
145If a socket is not associated with any file descriptor,
146the first four columns have no meaning.
147.Sh SEE ALSO
148.Xr fstat 1 ,
149.Xr netstat 1 ,
150.Xr procstat 1 ,
151.Xr inet 4 ,
152.Xr inet6 4 ,
153.Xr protocols 5
154.Sh HISTORY
155The
156.Nm
157command appeared in
158.Fx 3.1 .
159.Sh AUTHORS
160The
161.Nm
162command and this manual page were written by
163.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
164