On Linux to list running services and open ports, I either use netstat
or ss
(socket stat?) most recently.
Though netstat
is available on FreeBSD, the syntax is completely different.
Today, I have the need to list the running services with the port display. On FreeBSD, we can do this using sockstat
command.
root@bsd1:~ # sockstat -4 -l
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
minio minio 49274 10 tcp46 *:9000 *:*
root sendmail 675 4 tcp4 127.0.0.1:25 *:*
root sshd 672 4 tcp4 *:22 *:*
ntpd ntpd 616 21 udp4 *:123 *:*
ntpd ntpd 616 22 udp4 149.171.180.154:123 *:*
ntpd ntpd 616 25 udp4 127.0.0.1:123 *:*
root syslogd 523 7 udp4 *:514 *:*
Here are some other options which can be passed to the sockstat
command:
- -6 : displays IPv6 sockets only
- -c : only displays connected sockets
Reference: