


If the process is not running at that moment you will not receive any output, You can use the -V verbose parameter along with the above command to get detail of processing. If you want to check for the specific port status you need to provide a port number like the below command.


The output we receive has the following information like service name, process ID ( PID), user, type of protocols and the port the number which is LISTEN. To filter which port is listening we will use grep command along pipe line $ sudo lsof -i -P -n | grep LISTEN systemd-r 521 systemd-resolve 13u IPv4 21271 0t0 TCP 127.0.0.53:53 (LISTEN)Ĭupsd 557 root 6u IPv6 25013 0t0 TCP :631 (LISTEN)Ĭupsd 557 root 7u IPv4 25014 0t0 TCP 127.0.0.1:631 (LISTEN) -n :- This flag will ensure that port number should show on screen.-P :- It is used show the numerical address instead of hostname.-i It is used to select IPv4 and IPv6 files.To check the port status using lsof in your Ubuntu or Debian pass the following command into your Linux Terminals $ sudo lsof -i -P -n lsof Command stands for list open files.Ī lsof command provide the details of the open process, such as sockets like TCP and UDP like a running background file not only the socket you can get information about directories, devices, etc. Lsof command is a powerful utility through which we can check the port status. Please check that if you want to know more about Nmap.
#Bash netcat port check manual#
This was not only single way to audit port status nmap has many other flags which give your more details to check read manual page.Ī few days back, we have written a complete guide on Nmap. This was for TCP port when you want to check for the UDP port use flag -sU $ sudo nmap -sU -p- 10.10.8.8 – 172.27.244.158:- We have passed the IP address, you can even pass the domain name or server name.įrom the output, we are getting the information like port number 22,80 are open and the rest ports are closed.-p:- This will make sure to scan all the port 65535 number.Now we explain to you the flags or parameter that we used above in the above command When you pass this command, It will show you details like Port number, state, and type of service To check the port status in your Ubuntu or Debian pass the following command into your Linux Terminals $ sudo nmap -sT -p- 172.27.244.158 Nmap is the all in one network tool which can list you all the port which is active on your system or remote system with many features. There are many through which you can check the port status like Nmap, netstat, ss, or lsof, and We will take an example of each command. I think so explanation make clear what is port and listening port. If my friend don’t open the door or not received my call for any reason then the security guard (Firewall) will not allow me to get inside his apartment and my connection get dropped. To clear concept:- When I need to visit one of my friend’s houses I should know his apartment address (IP address) Unique for everyone and the flat number like (port number).
#Bash netcat port check how to#
How to check active or Listening Port Statusīefore that, first, understand what is an active or Listening port? From the above instance, you know what is a port? Now understand what is Listening to port? Listening port is like communication between end-to endpoint using TCP or UDP protocol and every machine is assigned with a unique IP address. When you know the friend’s house door number, you can only get inside your friend’s house. In short, a port is like a door number of your friend’s house. The Internet Protocol suite uses it to communicate through User Diagram Protocol UDP or Transport Layer Protocol TCP.Ī port number is a 16-bit unsigned integer that ranges from 0 to 65535.
