1

My question is what does it mean to LISTEN or ACCEPT on a port as it relates to my example?

Example: I have a tomcat server, and It will use port 8080. I want to make sure that port is available for me to use.

What commands should I perform on my unix server and why?

what information would a command like this give me: netstat -an | grep LISTEN

1

You could try sudo lsof -i :8080. That will list the processes doing anything with your port.

  • You have not answered any part of my question with this response. – TazMan Oct 27 '13 at 5:08
1

It's better to use :

netstat -ant | egrep :8080

But its parameters:

-a : all
-t TCP protocol
-n numeric, don't use name

please attention to my example for port 80:

tcp        0      1 192.168.1.7:57511       182.50.136.239:80       SYN_SENT   
tcp        0      1 192.168.1.7:57547       182.50.136.239:80       SYN_SENT   
tcp        0      1 192.168.1.7:57512       182.50.136.239:80       SYN_SENT   
tcp        0      1 192.168.1.7:57514       182.50.136.239:80       SYN_SENT   
tcp        0      1 192.168.1.7:57562       182.50.136.239:80       SYN_SENT   
tcp        0      1 192.168.1.7:57565       182.50.136.239:80       SYN_SENT   
tcp        0      1 192.168.1.7:57513       182.50.136.239:80       SYN_SENT   
tcp        0      0 192.168.1.7:39191       198.252.206.25:80       ESTABLISHED
tcp        0      1 192.168.1.7:57563       182.50.136.239:80       SYN_SENT   
tcp        0      1 192.168.1.7:57545       182.50.136.239:80       SYN_SENT   
tcp        0      0 192.168.1.7:39205       198.252.206.25:80       ESTABLISHED
tcp        0      1 192.168.1.7:57546       182.50.136.239:80       SYN_SENT   
tcp        0      1 192.168.1.7:57564       182.50.136.239:80       SYN_SENT   
tcp        0      0 192.168.1.7:49217       198.252.206.16:80       ESTABLISHED
tcp        0      0 192.168.1.7:39247       198.252.206.25:80       ESTABLISHED
tcp      957      0 192.168.1.7:42327       198.252.206.25:80       ESTABLISHED

First column is protocol, second : rec queue (numeric),3th: send queue(numeric) ,4th: local address+ port, 5th: foriegn host:port , 6th: handshaking state such as LISTEN, SYN and so on.

Even you can use :

netstat -antp |egrep tomcat

I example mysql for u :

root@debian:/home/mohsen# netstat -antp |egrep mysql

tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      24783/mysqld    

A new column has been appended, yes pid/porgram.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.