Netstat is the command you need:
sudo netstat -alpntu4
Where:
a = Show both listening and non-listening sockets.
l = Show only listening sockets.
p = Show the PID and name of the program to which each socket belongs.
n = Show numerical addresses instead of trying to determine symbolic host, port or user names.
t = TCP
u = UDP
4 = IPv4 only
Advertisements