The BSD sockstat(1) command


In today’s installment of things you already know, unless you don’t, you can use sockstat(1) on the BSDs to list open sockets.

From the manpage(1), you can issue this command to show IPv4 sockets listening on port 22 using protocol TCP:

$ sockstat -4 -l -P tcp -p 22

I can’t tell you how many times this has saved me during a late-night troubleshooting session, when a service claims to be up but isn’t.

Author bio and support


Ruben Schade is a technical writer and infrastructure architect in Sydney, Australia who refers to himself in the third person. Hi!

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite bespoke cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or send a comment. Thanks ☺️.