To list open network ports and the processes that own them on FreeBSD OS with
netstat, you can use this command:
netstat -an | egrep 'Proto|LISTEN'
This information can be used to determine what services are running, in cases where services are using standard ports. On a FreeBSD system, you can get a listing of standard port associations by searching through the contents of
/etc/services. For instance, if you wanted to find out what was up with port 631, you might use this command:
grep -w 631 /etc/services
As with FreeBSD, the obvious choice of tool to use for listing open ports is
netstat. Most Linux distributions use a different version of the utility, however — maintained separately from the Linux distribution, as an independent software development project.
One consequence of that fact is that the command line options used to achieve the same results may be different with FreeBSD than with Debian, Ubuntu, or Fedora Core Linux systems. On a typical Linux system, this command will list open network ports and the processes that own them:
Microsoft Windows XP
Microsoft Windows also offers a
netstat command that can be executed from the command line to get a list of open ports. The standard MS Windows version of
netstat is slightly more limited than its Unix-like system counterparts, but still suffices to get a listing of listening services:
netstat -a | find "LISTENING"