Linux:netstat command

Source: Internet
Author: User
Tags domain name server

The netstat command is used to print the status information of network systems in Linux, allowing you to learn about the network conditions of the entire Linux system.

Grammar
Netstat (option)
Options
-A or--all: Displays the socket;-a< network type > or--< network type in all connections;: Lists the relevant addresses in the network type connection;-C or--continuous: Continuously list network status ;-C or--cache: Displays the cache information for the router configuration,-E or--extend: Displays other relevant information about the network;-F or--fib: Show fib;-g or--groups: Displays the multi-broadcast feature group members list;-H or--  Help: online assistance;-I or--interfaces: Displays the Web interface information form;-L or--listening: Displays the Socket;-m or--masquerade of the server in the monitor: shows the spoofed network connection ;-N or--numeric: use the IP address directly, not through the domain name server;-N or--netlink or--symbolic: Displays the symbolic connection name of the network hardware peripheral device;-O or--timers: Display timer ;-P or--programs: shows the program identification code and program name of the socket being used;-R or--route: Display routing table;-s or--statistice: Display network work information statistics ;-T or--tcp: Displays the connection status of the TCP transport protocol;-U or--UDP: Displays the connection status of the UDP transport protocol;-V or--verbose: Displays the instruction execution process;- V or--version: Displays version information; W or--raw: Displays the connection status of the raw transport protocol,-X or--unix: The effect of this parameter is the same as specifying the "-a Unix" parameter,--ip or--inet: The effect of this parameter is the same as specifying the "-a inet" parameter. 
Instance

List all ports (both listening and not listening)

Netstat-a     #列出所有端口netstat-at    #列出所有tcp端口netstat-au    #列出所有udp端口                             

List all Sockets in the listening state

Netstat-l        #只显示监听端口netstat-lt       #只列出所有监听 TCP port netstat-lu       #只列出所有监听 UDP port netstat-lx       #只列出所有监听 UNIX Port

Show statistics for each protocol

Netstat-s   Display statistics for all ports netstat-st   display statistics for TCP ports netstat-su   displays statistics for UDP ports

Show PID and process name in netstat output

Netstat-pt

netstat -pCan be used in conjunction with other switches, you can add "Pid/process name" to the netstat output, so debugging can easily find a specific port to run the program.

Hosts, ports and usernames (host, port or user) are not displayed in the Netstat output

When you do not want to let the host, port and user name display, use netstat -n . Numbers will be used instead of those names. The output can also be accelerated because there is no comparison query.

Netstat-an

If you just don't want one of these three names to be displayed, use the following command:

Netsat-a--numeric-portsnetsat-a--numeric-hostsnetsat-a--numeric-users

Continuous output netstat information

Netstat-c   #每隔一秒输出网络信息

Show address families not supported by the system (addr families)

Netstat--verbose

At the end of the output, the following information is available:

Netstat:no support for ' AF-IPX ' on the ' system.netstat:no support for ' AF AX25 ' on this system.netstat:no AF X25 ' on the System.netstat:no support for ' AF Netrom ' on the This system.

Show Core Routing information

Netstat-r

Use netstat -rn the display number format without querying the host name.

Find out which port the program is running on

Not all processes can be found, no permissions will not be displayed, use root permissions to view all the information.

Ssh

Locate the process running on the specified port:

Netstat-an | grep ': 80 '

Show list of network interfaces

Netstat-i

Displays detailed information, such as ifconfig use netstat -ie .

IP and TCP Analysis

To view the most connected IP addresses for a service port:

Sort-nr

TCP Various status lists:

Netstat-nt | Grep-e 127.0.0.1-e 0.0.0.0-e.:::-V | awk '/^tcp/{++state[$NF]} END {for (I in State) print I, "\ T", state[i]} '

View the number of phpcgi processes, and if they are close to the preset, they are not enough and need to be increased:

Netstat-anpo | grep "wc-l

Linux:netstat command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.