Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

How to list files in hadoop?

Ads

 
 

Share on Google+Share on Google+

Java Coder
How to list files in hadoop?
1 Answer(s)      2 months and 10 days ago
Posted in : Big Data

Hi,

I want to list the files from a directory in HDFS. How to list files in hadoop?

Thanks

Ads
View Answers

May 13, 2017 at 7:27 PM


Hi,

Hadoop uses its own file system which is know as Hadoop File System or HDFS.

Hadoop provides commands to interact with the HDFS. To list down all the file in a directory you can use the following command:

hadoop fs -ls /

Above command lists all the files from the root of HDFS.

Sample output:

[email protected]:/home/deepak$ hadoop fs -ls /
Found 11 items
drwxrwxrwx   - yarn   hadoop          0 2017-05-13 18:33 /app-logs
drwxr-xr-x   - hdfs   hdfs            0 2016-04-26 19:30 /apps
drwxr-xr-x   - yarn   hadoop          0 2016-04-25 20:57 /ats
drwxr-xr-x   - hdfs   hdfs            0 2016-04-25 20:58 /hdp
drwxr-xr-x   - mapred hdfs            0 2016-04-25 20:58 /mapred
drwxrwxrwx   - mapred hadoop          0 2016-04-25 20:58 /mr-history
drwxrwxrwx   - spark  hadoop          0 2017-05-13 19:26 /spark-history
drwxr-xr-x   - hdfs   hdfs            0 2017-05-13 10:51 /system
drwxr-xr-x   - hdfs   hdfs            0 2017-05-11 22:52 /test
drwxrwxrwx   - hdfs   hdfs            0 2016-04-25 21:02 /tmp
drwxr-xr-x   - hdfs   hdfs            0 2017-05-13 18:33 /user
[email protected]:/home/deepak$

Check more at Hadoop shell commands.

Thanks


Ads