netstat -ltpn

e.g.

(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
 Active Internet connections (only servers)
 Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
 tcp        0      0 0.0.0.0:29418           0.0.0.0:*               LISTEN      2517/GerritCodeRevi
 tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      -
 tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      2517/GerritCodeRevi
 tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -

note:

     -p, --programs           display PID/Program name for sockets #进程号与进程名 (太好了,可读性很好)
     -n, --numeric            don't resolve names # ip不用解析为域名,而是直接显示(因为本机没有域名,所以解析为*)
     -l, --listening          display listening server sockets #只看listening
     <Socket>={-t|--tcp}