As a Linux system administrator, to lớn transmit data from vps to server having a good command over the TCP (Transmission Control Protocol) protocols is very much crucial. In the term of TCP, we get the idea of two types of ports: xuất hiện port & Close port. In-network transmission control protocol, all the ports which have accepted transmission of data are called xuất hiện port, & on the other hand, the ports where data packets are filtered or couldn’t reach are called close port. Those who have been working with Ubuntu vps management must know the havoc of not maintaining networks mở cửa ports properly. The knowledge between the xuất hiện port & close port is pretty vice versa. In the Linux networking system, understanding the concept of xuất hiện ports & checking the available number of mở cửa ports is vital.

Bạn đang xem: How to check all the open ports in your linux system

Checking open Ports in Linux

Network ports are usually allocated just after the IP address. Let your network address followed by a 16-bit socket, then the total number of available ports will be 2^16= 65536. In computer networking, we all are familiar with the concept and types of networking addresses like physical address & local address.

Every networking address has an endpoint that defines the work-type of that network address. Let, we want lớn send an email from our gmail account; in this case, gmail uses the SMTP (Simple Mail Transfer Protocol) system. We know that SSL (Secure Sockets Layer) is a socket number used for identification and security purpose.

In a word, this socket is called port. For Gmail, the mặc định SSL or port is 465. The internet service provider(ISP) often allows its users to download movies of games from their tệp tin Transfer Protocol (FTP) server. Most of the time, FTP servers are made with Apache Ubuntu server tools, where ports are kept mở cửa and associated with IP addresses. In the entire post, we cover up the method of how to check open ports in Linux as well as in Ubuntu.

Port Range Category
0 – 1023System Ports
1024 – 49151User Ports
49152 – 65535Dynamic Ports

1. Checking xuất hiện Ports Using nmap Command in Linux

In Linux, Network Mapper or nmap command is used for checking the status of a system, used devices, checking current network services, & the availability of socket or ports. If your Linux system doesn’t have nmap installed, for Ubuntu và other Linux versions, you can install nmap by the following terminal commands. You can also kiểm tra the version of your network mapper.

$ sudo apt-get install nmap$ nmap --versionAfter the nmap is installed, at the very first step, we can check the ports of our localhost address. Most of the time, the localhost IP address is assigned by

$ sudo nmap -sT -O localhost


We can also find the Transmission Control Protocol (TCP) ports using the nmap command. The namp command is also used for finding the available ports for a particular IP Address. Let we want to kiểm tra the ports for the IP

$ sudo nmap$ nmap -open$ nmap

2. Finding xuất hiện Ports Using netcat Command in Ubuntu

Previously we have seen how to check available ports using Transmission Control Protocol. Now we will see how to kiểm tra the available number of ports using the User Datagram Protocol (UDP).

In the Ubuntu server, this kind of networking operations is done by using the nc or netcat command. Và I must say that in Linux, the netcat is the most powerful weapon to check network sockets. Let you want to create a connection under a TCP protocol where the port is assigned as 2389.

Now you can run the following terminal command to lớn create a TCP connection. Or, if you are the client, you have access to lớn the localhost; you can run the second terminal command too.

$ nc -l 2389$ nc localhost 2389

3. Finding mở cửa Ports Using netstat Command in Linux

If you want to check only the UDP User Datagram Protocol ports, you can also use the network statistics or netstat command. The netstat command can display both receiving và sending over transmission data. Finally, we have one command that can find mở cửa ports in Linux by netstat.

$ netstat --listen$ netstat -lntu$ netstat -vaun


The NGINX command is also used lớn monitor the networking system of your Linux. Here I’m introducing you with a nignx command that can kiểm tra the xuất hiện ports of your Linux system. 

$ sudo netstat -lntup | grep "nginx"If you find the nignx is not working correctly, try reloading the nignx.

$ sudo nginx -t$ sudo nginx -s reloadTo find all the open ports in your Linux system, you can use this terminal command. 

$ netstat -antplF


For finding the specific port status in Linux, there is a netstat command which can display all listening ports. Let, our specific port is 80. 

$ sudo netstat -lntup | grep ":80"

 4. Monitor Listening Ports Using lsof Command in Ubuntu

In Linux, a danh mục of mở cửa files or in short lsof command is used lớn see the các mục of files or directories which are open. But we can also use the lsof commands for some simple networking tasks. We can find the menu of all xuất hiện ports by lsof commands. I must mention that in Linux, open port is also aliased by listening port.

Let, we want to kiểm tra the connected foreign addresses and the listening ports using the lsof command. Here, listening or listen is referred to as mở cửa ports. In the terminal, we can use exact data text grabber or Global regular expression print or, in short, the grep command.

$ lsof -i$ sudo lsof -i -P -n | grep LISTEN$ lsof -i TCP| fgrep LISTEN


If you want to kiểm tra the status of a specific port against an IP address of the network, you can use this terminal command in your Linux system. Let, we want to check the status for the port 80.

$ sudo lsof -i :80 

5. Finding Established Ports Using ss Command in Linux

In Linux, the ss command is referred khổng lồ the term socket statistics. Here the sockets are assigned as ports. So by using the ss command, we can determine the open ports in the Linux system. If you don’t have ss installed in your Linux, you can quickly install ss in your machine from the apt command given below. Then run the sockstat command in your terminal. In the output, you will find the socket/port details.

$ sudo apt install sockstat $ sockstat$ netstat -an |grep LISTEN


For more informative open port checking purposes, there is a lntu command in Linux. The lntu command mainly looks for the details of TCP mở cửa ports, UDP open ports, name of the software, và used port number.

$ ss -lntu

Final Thoughts

For networking, open ports can be checked by using C++ or PHP, but the best way to kiểm tra all mở cửa or listening ports is khổng lồ use the Linux command lines. These will make your time efficient. In this post, we have tried lớn show some dynamic methods of checking mở cửa ports of the Linux system. In some Linux distributions like Ubuntu and Red Hat, checking mở cửa ports và close ports are unavoidable for firewall security purposes. You can find SMTP ports, Network Time Protocol (NTP) ports, HTTP ports, and UDP ports using the commands described above.

Xem thêm: Windows 10 Home Single Language Là Gì, Phân Biệt Các Phiên Bản Windows 10 Hiện Nay

The entire post was all about how ports are assigned with IP addresses và why you can check the mở cửa or closed ports in your Linux system. If you find this post useful, please let us know what you’ve loved in this post. And you can also write a phản hồi about this post. Feel không tính tiền to giới thiệu this post among your Linux geeks.