If you want searching how to find listening port in Linux, this article will help you. We will find listening port in Linux using 4 commands.
A port is an access point that an operating system makes available so that it can facilitate network traffic with other devices or servers, while also differentiating the traffic in order to understand what service or app the traffic is being sent to.
Let’s get started.
1. We will start with Netstat command
Netstat (network statistics) command used for finding problems and find out listening ports in the network and to determine the amount of traffic on the network as a performance measurement. On Linux this program is mostly obsolete, although still included in many distributions.
Display open port:
# netstat -lntup
- l – it tells netstat to print all listening ports.
- n – display numeric values rather than service name.
- t – shows all TCP connections.
- u – shows all UDP connections.
- p – display application/program name listening on the port.
Use grep command to find out specific service/port
# netstat -lntup | grep “apache”
# netstat -lntup | grep “:80”
2. Next, we will see ss command
The ss command is a tool used to dump socket statistics and displays information in similar fashion (although simpler and faster) to netstat. The ss command can also display even more TCP and state information than most other tools.
# ss -lntu
This command will display listening TCP and UDP connections in numeric value.
3. Now, we will see Nmap Command
Nmap (“Network Mapper”) is a free and open source utility for network discovery and security auditing. Many systems and network administrators also find it useful for tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime.
We need to install Nmap using following command:
# apt install nmap [On Debian/Ubuntu]
# yum install nmap [On CentOS/RHEL]
# dnf install nmap [On Fedora 22+]
To scan all open/listening ports in your Linux system, run the following command
# nmap -n -PN -sT -sU -p- localhost
4. Finally, we will see lsof Command
lsof is a command meaning “list open files”, which is used in many Unix-like systems to report a list of all open files and the processes that opened them.
To list all Internet and network files.
# lsof -i
Find out specific port
# lsof -i :80
We have seen how find listening port in Linux using 4 commands in details.
[Need assistance to fix this error or install tools? We’ll help you.]