Hadoop FS Shell ls

HadoopHadoopBeginner
Practice Now

Introduction

Imagine a magical night sky filled with twinkling stars above, where a brave interstellar explorer embarks on a thrilling adventure. In this scenario, our goal is to navigate through the Hadoop HDFS using the "FS Shell ls" command to unveil hidden treasures of data and information in the vast digital universe.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL hadoop(("`Hadoop`")) -.-> hadoop/HadoopHDFSGroup(["`Hadoop HDFS`"]) hadoop/HadoopHDFSGroup -.-> hadoop/fs_ls("`FS Shell ls`") subgraph Lab Skills hadoop/fs_ls -.-> lab-271872{{"`Hadoop FS Shell ls`"}} end

Exploring the Hadoop File System

In this step, we will dive into the realm of the Hadoop File System (HDFS) and use the hadoop fs -ls command to list directories and files.

  1. Switch to the Hadoop user:

    su - hadoop
  2. List the contents of the user's home directory in HDFS:

    hadoop fs -ls /

    the command run successfully means the Hadoop environment is ready and we can use hadoop command.

Let's continue our journey by navigating further into directories within HDFS using the hadoop fs -ls command.

  1. Create a new directory in HDFS:

    hadoop fs -mkdir /lab
  2. List the contents of the newly created directory:

    hadoop fs -ls /

Exploring File Details

In this step, let's delve into the details of specific files within HDFS by using the hadoop fs -ls command with a file path.

  1. Upload a sample file to the lab directory in HDFS:

    echo 'Hello, Hadoop!' > sample.txt
    hadoop fs -put sample.txt /lab
  2. List details of the uploaded file:

    hadoop fs -ls /lab/sample.txt

Summary

In this lab, we embarked on a journey through the Hadoop File System using the "FS Shell ls" command to explore directories, navigate through paths, and uncover file details. By following the step-by-step instructions and leveraging the power of Hadoop, users can enhance their understanding of HDFS and effectively manage data within the distributed environment.

Other Hadoop Tutorials you may like