Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to navigate directories in Hadoop HDFS

Tags:

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

like image 834
2Big2BeSmall Avatar asked Oct 10 '15 15:10

2Big2BeSmall


People also ask

How do I list directories in Hadoop?

The following arguments are available with hadoop ls command: Usage: hadoop fs -ls [-d] [-h] [-R] [-t] [-S] [-r] [-u] <args> Options: -d: Directories are listed as plain files. -h: Format file sizes in a human-readable fashion (eg 64.0m instead of 67108864). -R: Recursively list subdirectories encountered.

How do I find my current directory in Hadoop?

Using the ls command, we can check for the directories in HDFS. Hadoop HDFS mkdir Command Description: This command creates the directory in HDFS if it does not already exist. Note: If the directory already exists in HDFS, then we will get an error message that file already exists.

How do I move files from one folder to another in HDFS?

You can use the cp command in Hadoop. This command is similar to the Linux cp command, and it is used for copying files from one directory to another directory within the HDFS file system.


1 Answers

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/ 
like image 147
YoungHobbit Avatar answered Sep 21 '22 13:09

YoungHobbit