O'Reilly logo

LPI Linux Certification in a Nutshell, 3rd Edition by James Stanger, Bruno Gomes Pessanha, Stephen Addison Schneiter, Adam Haeder

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

netstat

Syntax

netstat [options]

Description

Depending on options, netstat displays network connections, routing tables, interface statistics, masqueraded connections, and multicast memberships. Much of this is beyond the scope of the LPIC Level 1 Exams, but you must be aware of the command and its basic use.

Frequently used options

-c

Continuous operation. This option yields a netstat display every second until interrupted with Ctrl-C.

-i

Display a list of interfaces.

-n

Numeric mode. Display addresses instead of host, port, and usernames.

-p

Programs mode. Display the process ID (PID) and process name.

-r

Routing mode. Display the routing table in the format of the route command.

-v

Verbose mode.

Examples

Display the interfaces table and statistics (the example output is truncated):

# netstat -i
Kernel Interface table
Iface MTU  Met   RX-OK RX-ERR RX-DRP RX-OVR  TX-OK
eth0  1500 0   1518801     37      0      0  713297
lo    3924 0    365816      0      0      0  365816

To show all current connections without resolving hostnames and protocol names:

# netstat -an --tcp Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:34031 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN tcp 1 0 10.41.81.148:59667 10.41.0.47:3268 CLOSE_WAIT tcp 0 0 10.41.81.148:45449 64.4.34.61:1863 ESTABLISHED tcp 0 0 10.41.81.148:53284 10.41.0.32:143 ESTABLISHED tcp 0 0 10.41.81.148:33722 10.41.0.38:22 ESTABLISHED tcp 0 0 10.41.81.148:42261 74.125.77.83:443 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required