How to check which process a port is occupied in Linux?

青灯夜游
Release: 2020-08-24 11:24:39
Original
7157 people have browsed it

How to check which process a port is occupied in Linux: 1. Use "lsof -i:port number" to check; 2. Use "netstat -tunlp |grep port number" to check.

How to check which process a port is occupied in Linux?

Linux method to check which process the port is occupied

1.lsof -i:port number

2.netstat -tunlp |grep port number

You can check which process the specified port is occupied


[Step 1]lsof -i

lsof -i is used to display the process status that meets the conditions

lsof (list open files) is a Lists the tools used to open files on the current system.

Execute the lsof -i command as the root user, as shown below

##Execute the lsof -i command as the root user


The meaning of each column of information is as follows:
command: name of the process PID: process identifier
USER: process owner
FD: file descriptor, the application identifies the file through the file description. Such as cwd, txt, etc.
TYPE: file type, such as DIR, REG, etc.
DEVICE: Specify the disk name
SIZE: The size of the file
NODE: Index node (identification of the file on the disk)
NAME: The exact name of the open file

[Step 2]

lsof -i: Port number

lsof -i: Port number, view the specified The occupancy of a port, for example, check the usage of port 22:

[Step 3]

netstat -tunlp

netstat - tunlp is used to display tcp, ucp ports and processes and other related information, as shown below:

-t (tcp) Only displays tcp related options -u (udp ) Only display udp related options

-n Refuse to display column names, convert all numbers that can be displayed into numbers

-l Only display the service status in listen

-p Program name to display potential related links

[Step 4]

netstat -tunlp |grep port number

netstat -tunlp |grep port number , used to view the process of the specified port number, such as viewing port 22

Related recommendations: "

Linux Video Tutorial"

The above is the detailed content of How to check which process a port is occupied in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!