How to navigate directories in Hadoop HDFS
Asked Answered
C

4

26

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

Clingfish answered 10/10, 2015 at 15:1 Comment(0)
R
43

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/
Rightism answered 10/10, 2015 at 15:8 Comment(1)
ugh. that sux. but it is what it is. Thanks.Spermic
R
8
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.

Raveaux answered 4/7, 2017 at 6:18 Comment(1)
so for the question need to do sudo -u hdfs hadoop fs –ls hdfs:///hbase ?Cuticula
M
1

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

Matthaus answered 7/4, 2021 at 9:31 Comment(0)
M
0

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
Merlynmermaid answered 21/4, 2018 at 17:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.