Netstat
allows you to check the state of ports on the local host.
On Windows
-adisplays all connections (active TCP and UDP connections plus ports in the listening state).-oshows the Process ID (PID) number that has opened the port.-bshows the process name that has opened the port.-ndisplays ports and addresses in numerical format. Skipping name resolution speeds up each query.-sshows per protocol statistics (such as packets received, errors, discards, unknown requests, port requests, failed connections, and so on).-pproto displays connections by protocol (TCP or UDP or TCPv6/UDPv6). When used with-s, this switch can also filter the statistics shown by IP, IPv6, ICMP, and ICMPv6.-rshows the routing table.-edisplays Ethernet statistics.
On Linux
‑tfor TCP Internet connections‑ufor UDP Internet connections‑wfor raw connections‑xUNIX sockets/local server ports-aincludes ports in the listening state in the output.-lshows only ports in the listening state (omits established connections).-pshows the Process ID (PID) number that has opened the port (similar to-oon Windows).-rshows the routing table.-sdisplays protocol statistics (as in Windows).-idisplays interface statistics (similar to-eon Windows).-edisplays extra information.-csets output to update continuously.
example
For example, the following command shows Internet connections (TCP and UDP) only: netstat ‑tu
Backlinks