How to view the developed ports under the Linux system

Source: Internet
Author: User

Introduction: In a Linux server, it is often necessary to see whether certain ports on the system are open properly, or to know which processes occupy a particular port service, so this command is very common, and this article describes the common methods of these commands.

1. See if a particular port is turned on or occupied

List all the TCP connections in the Listening state:


Command parsing:

-l list all listening ports

-N Displays the address and port number in digital form, without parsing the domain name and speeding up the display of the information.

-P shows the process that occupies the port number

-T lists connections for the TCP protocol

-A lists all connections for all sockets under all current connections, TCP, UDP, and UNIX protocols

-U lists UDP connections

For an example of whether to use domain name resolution for-N:

As you can see from the content,-n controls whether the domain name is displayed.

List all the TCP ports in the listening state

Netstat-alt

To find a process for a specific port:

To view the name or user ID of the owner:

Netstat-altep

Lists the user IDs that TCP belongs to in the current process

Netstat-altne

Here, if you will - NAnd - eoption, the properties of the user column are the ID numbers of the users, not the user names. Use -epOption to view both the process name and the user name

-S lists the statistics of the Network information:

-R Lists Routing information

-I print out the network interface information, E and its collocation, can output more friendly information.

Output Network interface information:

Netstat-ie

2. lsof command

Command format: Lsof-i:p ort_number to find a process or command for a specific port

Lsof-i: 8010

3. How to find help information

In Linux, a powerful command man is provided to help us find the most comprehensive introductory information.

Mans netstat

4. Summary

Netstat is a very powerful command, it can provide most of the information needed, lsof is also a very useful tool, but under certain circumstances, lsof may not be able to find out, but Netstat can be queried.

Priority recommendation Nestat to query ports.



How to view the developed ports under the Linux system

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.