title: finding out which ports a program/process ist listening to - lsof, netstat
body: <p>Under Ubuntu I'm having an interactive program that I'm suspecting it is hanging listening on a specific port, don't know which one.</p>
  
  <p>It is a shell script that invokes a java command in its last line.</p>
  
  <p>How can I easily find out the ports it is listening to in the state when it is "hanging"?</p>
  
  <p>I tried to put lsof in front of the command but a huge path is written out and it says "lsof: path too long"</p>
  
  <pre><code>lsof -c java  ${JAVA_OPTS} -classpath "${SERVLET_API}:${JSP_API}:${OPENCMS_CLASSPATH}:${TOMCAT_CLASSPATH}:${OPENCMS_BASE}/classes" org.opencms.main.CmsShell -base="${OPENCMS_BASE}" "$@"
  </code></pre>