What is the command to view the port in Linux?

藏色散人
Release: 2023-03-10 09:32:11
Original
7994 people have browsed it

The command to view ports under Linux is the netstat command. You can use the netstat command to know the network status of the entire Linux system; the syntax for using this command is "netstat [-acCeFghilMnNoprstuvVwx][-A][--ip ]", setting the "-t" parameter will display the TCP port, and setting the "-u" parameter will display the UDP port.

What is the command to view the port in Linux?

The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

What is the command to view the port in Linux?

The Linux netstat command is used to display network status.

Using the netstat command allows you to know the network status of the entire Linux system.

Syntax:netstat [-acCeFghilMnNoprstuvVwx][-A<Network Type>][--ip]

##Common commands for linux to view ports

netstat command parameters:

-t: Specify the TCP port to display

-u: Specify the display UDP port

 -l: Only display the listening socket (the so-called socket is a program that enables the application to read, write, and send and receive communication protocols and data)

 -p: Display process identifier and program name. Each socket/port belongs to a program.

 -n: Do not perform DNS polling, display IP (can speed up the operation)

can display all ports and process services on the current server, in Combining grep can check a specific port and service situation··

netstat -ntlp//查看当前所有tcp端口·
netstat -ntulp |grep80//查看所有80端口使用情况·
netstat -an | grep3306//查看所有3306端口使用情况·
Copy after login

Check which services and ports are on a server

netstat  -lanp
Copy after login

Check how many ports a service has. For example, you want to check mysqld

ps -ef |grep mysqld
Copy after login

to check the number of connections of a certain port, such as 3306 port

netstat -pnt |grep :3306|wc
Copy after login

to check the connection client IP of a certain port, such as 3306 port

netstat -anp |grep3306
Copy after login
netstat -an 查看网络端口
Copy after login

lsof -i :port, use lsof -i :port to see the program running on the specified port, as well as the current connection.

nmap 端口扫描
netstat -nupl  (UDP类型的端口)
netstat -ntpl  (TCP类型的端口)
netstat -anp 显示系统端口使用情况
Copy after login

Related recommendations: "

Linux Video Tutorial"

The above is the detailed content of What is the command to view the port 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template