SyntaxHighlighter JS

2013-01-22

Find Unused Unix Ports

Problem:
You need to bring up another Unix web server but port 80 is already in use. How do you find another unused Unix port?

Solution:
(as one line)

netstat -ln | grep -v LISTENING | awk '{print $4}' | grep ":" | sort | uniq


You will get an output like

0.0.0.0:5353
0.0.0.0:68
0.0.0.0:80
10.0.2.15:123
::1:10089
::1:123

The number after the last colon is the port in use, e.g. 80, 123, 5353.  Pick any Unix port not already in use and assigned.

No comments:

Post a Comment