Common Operations on Linux and Windows ports: linuxwindows Port

Source: Internet
Author: User

Common Operations on Linux and Windows ports: linuxwindows Port
Common Operations on Linux and Windows ports

 

I. Introduction

During the development process, you will often encounter problems where the port is occupied, and occasionally encounter problems where tomcat runs normally on the server, starts normally, runs normally, but cannot be accessed externally! Sometimes we clearly know what program occupies the port, but sometimes we have to use commands to check which program occupies the specified port. There is also a small number of cases. whether the port is open to the outside, especially in Linux.

 

Ii. Port operations specified by Windows

 

1: main Commands

 

Main commands (only function introduction, detailed use xxx /? View ):

A) netstate -- mainly used to view port information. For Windows and Linux, parameters are different.

B) tasklist -- list the running processes.

C) taskkill -- forcibly terminate the specified operation.

For example, when we start tomcat, we always prompt that port 8080 is occupied! Assume that you do not know the port occupied by the Program, (if you know, this is also an additional debugging method) how can I find out which program occupies port 8080 and how to end the process and release port 8080.

2: specific process

A) Open the command line window: ctrl + r -- cmd, and a piece of black appears:

 

B) query the process PID occupied by port 8080 (multiple *. 148: 8080 occurs because the agent used by the local machine is 148: 8080 ):

 

C) Check the process whose PID is 7904:

 

 

D) after knowing the process name, we can end the process to release port 8080. There are two methods: one is to use the task manager to find javaw.exe to forcibly end the process, which is very easy. The other method is to end with the command line:

 

Note: The/im parameter must be followed by the name of the terminated process.

 

Iii. Linux port-specific operations

 

1: main Commands

 

A) netstate -- view the specified port information

B) ps -- View System Process Information

C) kill -- end the specified process information

 

2: specific process

The same scenario:

A) terminal input: netstat-anp | grep 8888:

 

 

B) Use ps to view the information of processes whose PID is 15315 (Optional). Focus on the first line:

 

 

C) use kill to end a process with the port 8888:

 

Port 8888 has been released.

 

Iv. test whether the specified port of the server is enabled

 

As mentioned above, tomcat is successfully started, and there is no exception information. It is still good before, but the machine cannot be accessed after it is restarted.

The reason may be that the firewall is enabled, so that the server does not develop port 8880 externally. In this case, you can use telnet to test whether the port is open. Note that the telnet remote connection is unencrypted, so it is very insecure. The main function is to test whether the port is open.

 

1: Test whether the port is open

 

A) Open the command terminal and enter telnet 10.45.35.65 8888:


If it is shown above, the connection fails (you can use the ping command to test whether the connection is successful, and then use telnet to test the port), or the port is not open.

Note: telnet uses an IP space port! 10.45.35.65 8888 instead of 10.45.35.65: 8888

If a dark area is displayed, the connection is normal and the port is open to the outside world:

 

In this case, you can use quite to exit:

 

V. Opening a specified port through the firewall in Linux

 

Sometimes disabling a firewall does not necessarily work, but what we need is that some specific ports can be opened to the outside, only in the firewall configuration file: add the following content to/etc/sysconfig/iptables to open the port (remember to modify it and restart the firewall: service iptables restart ):

 

Related Article

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.