Is there an equivalent to `pwd` in hdfs?
If you want to see the absolute path of home directory,you can make a empty directory and delete it,the information can show you the absolute path.
[test@test ~]$ hadoop fs -mkdir t1
[test@test ~]$ hadoop fs -rm -r t1
17/02/14 10:00:46 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 1 minutes, Emptier interval = 0 minutes.
Moved: 'hdfs://nameservice1/user/test/t1' to trash at: hdfs://nameservice1/user/test/.Trash/Current
'hdfs://nameservice1/user/test/t1' is the absolute path of the t1 directory
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 /
.
There is no -cd
command, so I guess you expect -pwd
to return the home directory.
According to this related question: HDFS Home Directory, the home directory of hdfs is always /user/<ShortUserName>
(it is hardcoded in the source).