One of the features of the powerful lsof tool allows for the discovery of a daemon’s port bindings. To examine them, simply issue the following command in the terminal.
lsof -nP -i
One may use the grep command to parse the output as seen in the below example.
lsof -nP -i | grep cupsd
Example output:
cupsd 2865 root 4u IPv4 8075 TCP 127.0.0.1:631 (LISTEN)
cupsd 2865 root 6u IPv4 8078 UDP *:631
Above we see that the cupsd process (PID 2865) is bound to TCP 631 and UDP 631.