A short one:
lsof -i -P -n | grep LISTEN
This will output all the ports the system is listing on. You might have to prepend “sudo”.
So then the command will be:
sudo lsof -i -P -n | grep LISTEN
might be helpful too. The command shows all the listing sockets of the Linux machine it is run on. (I added the “l” parameter to just show listing sockets.