Show open/in use ports

You can find out by using sudo netstat -tuna, which will show both the TCP and UDP ports that are being used.

The ports are listed with the IP addresses (here shown as "Local Address") after the colon like this:

127.0.0.1:1040

So 1040 is the port number.