180703 netstat common command learning summary

Time:2021-3-3

In normal work, a common case is to query the occupation of port number, which is generally used under LinuxnetstatIn MAC, it is usedlsofThis article records the use of netstat command in Linux

The most commonly used command to view the occupation of port number is as follows:

netstat -alnp | grep port

<!– more –>

1. Netstat usage

1. Parameter description

It is mainly to view the corresponding parameters

-A or -- all: displays the sockets in all connections;
-A < network type > or -- < network type >: list the related addresses in the connection of the network type;
-C or -- continuous: continuously list the network status;
-C or -- cache: displays the cache information configured by the router;
-E or -- extend: display other network related information;
-F or -- FIB: display FIB;
-G or -- groups: display the member list of multi broadcast function group;
-H or -- help: online help;
-I or -- interfaces: display network interface information form;
-L or -- listening: displays the socket of the server under monitoring;
-M or -- masquerade: display the disguised network connection;
-N or -- numeric: use IP address directly instead of domain name server;
-N or -- netlink or -- symbolic: displays the symbolic connection name of network hardware peripherals;
-O or -- timers: display timers;
-P or -- programs: displays the program ID and program name of the socket being used;
-R or -- route: displays the routing table;
-S or -- Statistics: display the statistical table of network work information;
-T or -- TCP: displays the connection status of TCP transmission protocol;
-U or -- UDP: displays the connection status of UDP transport protocol;
-V or -- verb: display the instruction execution process;
-V or -- version: display version information;
-W or -- raw: displays the connection status of raw transport protocol;
-X or -- UNIX: the effect of this parameter is the same as that of the "- a UNIX" parameter;
--IP or -- INET: this parameter has the same effect as specifying the "- a INET" parameter.

2. Common combinations

List all ports (listening and not listening)

netstat -a
Netstat - at # displays all TCP ports
Netstat - AU # displays all UDP ports

Lists all sockets in listening state

Netstat - L # show only listening ports
Netstat - LT # lists only all listening TCP ports
Netstat - Lu # only lists all listening UDP ports
Netstat - LX # lists all listening UNIX ports only

Display PID and process

netstat -pt

2. Others

0. Reference

1. A grey bloghttps://liuyueyi.github.io/he…

A gray personal blog, record all the study and work of the blog, welcome to visit

2. Statement

It’s not as good as a letter to the letter. It’s just a statement of one family. Due to my limited ability, it’s hard to avoid omissions and mistakes. If you find bugs or have better suggestions, you are welcome to criticize and correct them. Thank you very much

3. Scan attention