Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

share|improve this question
    
serverfault.com/questions/488486/… –  poige Oct 27 '13 at 16:29
add comment

2 Answers

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

share|improve this answer
    
You have not answered any part of my question with this response. –  TazMan Oct 27 '13 at 5:08
add comment

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.

share|improve this answer
    
Why using egrep if using none of regular expressions at all? O_o –  poige Oct 27 '13 at 16:28
    
Because almost i use regex, so it was a habi –  Mohsen Pahlevanzadeh Oct 27 '13 at 21:25
    
It's better having a habit to think –  poige Oct 27 '13 at 22:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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