Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to see if a port is in use

 
Manju choudhary
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,

i want to know how can i know if this port is in use or not (in unix).

eg if i change ssl port to 8444 should it be shown by "netstat -nap " command .
i tried but it does not show any entry for this.

how can i b sure than this port is not in use by any other app.

thanks
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a Linux/Unix question, not a JBoss question. Moving.

And when you write "in unix", what "unix" do you mean? Solaris?
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to occupy the port. If it is in use, you should get an error.

If it is free, you aren't sure whether it will be free in the next second, but of course you may use
with the appropriate hostname/IP instead of localhost.

nmap might need installation.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18009
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, there's 2 ways that a port might be in use. One is as a listener port, the other is as a reply port. Listener ports are things like 80, 8080, 25, 443, 5432 and so forth. Reply ports are dynamically assigned on a short-term as needed to faciliate a 2-way conversation. For example, to receive the response on an HTTP request or to maintain the client-inbound link on a client/server session.

For the most part, reply ports can be ignored. They're assigned from an unlikely set of numbers. To check for a listener port, use the "-l" option of netstat.

This should tell you if port 80 is in use, for example:



Feel free to use egrep if you don't want to cascade plain greps. And be sure to include the trailing space in the expression, or you get false hits on things like port 8080!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic