2Big2BeSmall
2Big2BeSmall

Reputation: 1378

How to navigate directories in Hadoop HDFS

I would like to navigate in HDFS

First i looked on the directories in "root" HDFS

[cloudera@localhost ~]$ sudo -u hdfs hadoop fs -ls hdfs:/
Found 5 items
drwxr-xr-x   - hbase hbase               0 2015-10-10 07:03 hdfs:///hbase
drwxr-xr-x   - solr  solr                0 2014-06-01 16:16 hdfs:///solr
drwxrwxrwx   - hdfs  supergroup          0 2015-10-08 11:45 hdfs:///tmp
drwxr-xr-x   - hdfs  supergroup          0 2015-04-13 08:26 hdfs:///user
drwxr-xr-x   - hdfs  supergroup          0 2014-06-01 16:15 hdfs:///var

then i tried entering one of them

[cloudera@localhost ~]$ sudo -u hdfs hadoop -cd hdfs:///hbase
Error: No command named `-cd' was found. Perhaps you meant `hadoop cd'

trying also 'hadoop cd' do not work

[cloudera@localhost ~]$ sudo -u hdfs hadoop cd hdfs:///hbase
Exception in thread "main" java.lang.NoClassDefFoundError: cd
Caused by: java.lang.ClassNotFoundException: cd
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: cd.  Program will exit.

Please don't offer to use -ls -R (recursive) to show all files .

I want to be able navigate using commands like cd

Upvotes: 26

Views: 93929

Answers (4)

chetan007
chetan007

Reputation: 9

You can make use of the UI to navigate http://<hostname of hdfs>:9870/explorer.html#/tmp or you can login to CDH UI, then click on the NameNode URL location.

NameNode URL location

Upvotes: 1

Muhammad Kashif Arif
Muhammad Kashif Arif

Reputation: 668

Guidline for cloudera psudo mode distribution code First use the

       hadoop fs -ls 

command Then see the directory let suppose there is folder of output So use this command to see inside ouput folder

       hadoop fs -ls ouput

Upvotes: 0

Amrutha Kalidindi
Amrutha Kalidindi

Reputation: 81

hadoop fs –ls /user/scott/

To see the list of values in the path, we have to give the full path. Other than that navigation is not possible.

Upvotes: 8

YoungHobbit
YoungHobbit

Reputation: 13402

There is no cd (change directory) command in hdfs file system. You can only list the directories and use them for reaching the next directory.

You have to navigate manually by providing the complete path using the ls command.

hdfs dfs -ls /user/username/app1/subdir/

Upvotes: 44

Related Questions