List Open Ports on macOS

4 July 2021 · 1 min read · OSX, shellfu, network

Contents

To list open ports on macOS use lsof (list open files). At the end of the day pretty much everything is a file handle in a Unix kernel. The following command filters down to only TCP ports in the LISTEN state:

1
lsof -i -n -P | grep TCP | grep LISTEN