Skip to Content

How to List Files and Folders Using Hadoop HDFS LS Command?

What Does Hadoop FS -ls Command Show in HDFS Directories?

Hadoop fs -ls lists HDFS files/directories with permissions, sizes, and replication details, essential for inspecting cluster storage, verifying data, and debugging MapReduce workflows.

Question

What is the role of Hadoop FS commands like -ls?

A. To replicate HDFS blocks
B. To format the NameNode
C. To list files and directories stored in HDFS
D. To configure reducers in MapReduce

Answer

C. To list files and directories stored in HDFS

Explanation

Hadoop FS commands like -ls provide a directory listing of files and directories in HDFS, displaying details such as permissions, replication factor, owner, group, file size, modification date/time, and path name in a format similar to Unix ls -l. Users run hadoop fs -ls /path to inspect HDFS structure, verify uploads, check space usage, or debug job inputs/outputs, with options like -R for recursive listing, -h for human-readable sizes, or -d for directory-only stats. This shell interface abstracts HDFS operations across local or remote clusters, unrelated to block replication (automatic), NameNode formatting (destructive one-time setup), or MapReduce reducer configuration (job submission parameter).