Home>Article>Operation and Maintenance> How to check which ports are open in Linux
Linux can check the opened ports through the following methods: 1. Use the netstat command "netstat -tuln", which will display all currently listening TCP and UDP ports; 2. Use the ss command "ss -tuln" " is used to display the currently listening TCP and UDP ports; 3. Use the lsof command "lsof -i" to display the currently open network connections and listening ports.
The operating system of this tutorial: Linux5.18.14 system, Dell G3 computer.
In Linux, you can use the following command to check which ports are open on the system:
1. Use the netstat command:
netstat -tuln
The The command will display all currently listening TCP and UDP ports. Among them,
-t means to display the TCP port,
-u means to display the UDP port,
-l means to display only the listening port, and
-n means to display the port number in numerical form.
2. Use the ss command:
ss -tuln
This command is similar to netstat and is used to display the currently listening TCP and UDP ports. Among them,
-t means to display the TCP port,
-u means to display the UDP port,
-l means to display only the listening port, and
-n means to display the port number in numerical form.
3. Use the lsof command:
lsof -i
This command will display the currently opened network connections and listening ports. Among them,
-i means only display network-related information.
These commands will list the listening ports on the system along with details of their status and associated processes. Note that executing these commands may require root or a user with appropriate permissions to view all port information.
Hope these commands are helpful to you! If you have any further questions, please feel free to ask.
The above is the detailed content of How to check which ports are open in Linux. For more information, please follow other related articles on the PHP Chinese website!