title: Find port number where HDFS is listening
body: <p>I want to access hdfs with fully qualified names such as :</p>
  
  <pre><code>hadoop fs -ls hdfs://machine-name:8020/user
  </code></pre>
  
  <p>I could also simply access hdfs with</p>
  
  <pre><code>hadoop fs -ls /user
  </code></pre>
  
  <p>However, I am writing test cases that should work on different distributions(HDP, Cloudera, MapR...etc) which involves accessing hdfs files with qualified names.</p>
  
  <p>I understand that <code>hdfs://machine-name:8020</code> is defined in core-site.xml as <code>fs.default.name</code>. But this seems to be different on different distributions. For example, hdfs is maprfs on MapR. IBM BigInsights don't even have <code>core-site.xml</code> in <code>$HADOOP_HOME/conf</code>.</p>
  
  <p>There doesn't seem to a way hadoop tells me what's defined in <code>fs.default.name</code> with it's command line options. </p>
  
  <p>How can I get the value defined in <code>fs.default.name</code> reliably from command line?</p>
  
  <p>The test will always be running on namenode, so machine name is easy. But getting the port number(8020) is a bit difficult. I tried lsof, netstat.. but still couldn't find a reliable way. </p>