Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
1  
If you wish to transplant the GNU netstat into BSD, you will probably need to compile it from source. – harrymc Apr 29 '13 at 7:27
up vote 7 down vote accepted
+50

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

share|improve this answer
    
this is exactly what i was looking for... thanks heaps – Howard May 1 '13 at 4:26

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

share|improve this answer
    
Thank you, but BSD netstat is different from GNU netstat. – Howard Apr 26 '13 at 10:38

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.