Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check whether particular port is open or closed on UNIX? [closed]

Tags:

unix

I am very new to unix. How can I check that a particular port is free or used right now ?

like image 494
arpanoid Avatar asked May 26 '11 13:05

arpanoid


People also ask

How check port is closed Linux?

Use ss command to display all open TCP and UDP ports in Linux. Another option is to use the netstat command to list all ports in Linux. Apart from ss / netstat one can use the lsof command to list open files and ports on Linux based system. Finally, one can use nmap command to check TCP and UDP ports too.


2 Answers

netstat -ano|grep 443|grep LISTEN 

will tell you whether a process is listening on port 443 (you might have to replace LISTEN with a string in your language, though, depending on your system settings).

like image 158
Frank Schmitt Avatar answered Oct 13 '22 00:10

Frank Schmitt


Try (maybe as root)

lsof -i -P 

and grep the output for the port you are looking for.

For example to check for port 80 do

lsof -i -P | grep :80 
like image 28
Hyperboreus Avatar answered Oct 13 '22 00:10

Hyperboreus