Diagnostic Tools

netstat is one of the most basic network service debugging tools, telling you what ports are open and whether any programs are listening on ports. For example, if you want to view all open TCP ports, run this command:

netstat -t

Table 6-2 lists the netstat options.

Table 6-2. netstat Options

Option

Description

-t

Prints TCP port information

-u

Prints UDP port information

-l

Prints listening ports

-a

Prints every active port

-n

Disables name lookups (useful if DNS isn't working)

Being able to list open and listening ports is good, but our good old friend lsof can go one step further.

lsof

In Finding Open Files with lsof you saw how lsof can track open files, but lsof can also list the programs currently using or listening to ports. For a complete ...

Get How Linux Works now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.