19

In Linux, netstat -lptun gives a list of servers with the following details:

  • protocol
  • local and foreign address
  • state
  • PID and program name

What is the command's equivalent in FreeBSD?

Thanks.

Howard
  • 2,336

3 Answers3

26

The command you want is sockstat. Use sockstat -4l to see just IPv4 listening sockets

botchitt
  • 326
2

On FreeBSD specifically, sockstat(1) is indeed useful.

You could also use fstat(1) on not just FreeBSD, but all modern BSD systems apart from OS X, although I guess fstat will only report presently open sockets each process may have, not the already closed ones recently. E.g., to omit non-internet files, try fstat | fgrep -e internet -e USER.

See also How to list open files on a UNIX system.

cnst
  • 2,615
-1

netBSD also have netstat program alongside their repository since netBSD 2.0, if on your machine doesn't have, you can install it, so you can use netstat on netBSD. here the guide http://modman.unixdev.net/?sektion=1&page=netstat&manpath=NetBSD-2.0