FreeBSD Unix Find Out Which Programs Are Listening On a Given Port Number

To find out which programs are listening on a given port number on a FreeBSD Unix system, you can use the sockstat command.

Here’s an example to find the program listening on port 80 (HTTP):

sockstat -4l | grep :80

The sockstat command displays information about active sockets, and the -4 option specifies that you want to display information about IPv4 sockets, while the -l option specifies that you want to display listening sockets only. The grep command is used to filter the output of sockstat and display only the line that contains the specified port number.

The output of the above command should be similar to the following:

www httpd 478846 7 tcp4 *:80 *:*

In this example, the program listening on port 80 is httpd, which is the Apache HTTP server. The www column shows the user that the program is running as, and the 478846 column shows the process ID (PID) of the program.

Leave a Comment