Is there an equivalent to `pwd` in hdfs?

merlin2011 picture merlin2011 · Feb 4, 2014 · Viewed 33.2k times · Source

I tried to do hdfs dfs -pwd, but that command does not exist. So currently I am resorting to doing hdfs dfs -ls .. followed by hdfs dfs -ls ../...

I also looked at the command listing for hdfs dfs but did not see anything that looked promising.

Is there a more direct way to find the absolute path?

Answer

Evgeny Benediktov picture Evgeny Benediktov · Feb 4, 2014

hdfs dfs -pwd does not exist because there is no "working directory" concept in HDFS when you run commands from command line.

You cannot execute hdfs dfs -cd in HDFS shell, and then run commands from there, since both HDFS shell and hdfs dfs -cd commands do not exist too, thus making the idea of working directory redundant.

Your home dir is always the prefix of the path, unless it starts from /.