Hadoop FS Shell chmod

HadoopHadoopBeginner
Practice Now

Introduction

Imagine a futuristic city where everything runs on advanced technology, including an extensive underground system managed by the city's eco-scientists.

In this scenario, you will step into the role of an eco-scientist tasked with setting permissions using Hadoop's HDFS Shell chmod command within the city's underground data storage infrastructure.


Skills Graph

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

Setting Permissions

In this step, you will learn how to set permissions using the chmod command in Hadoop's FS Shell.

  1. Switch to the hadoop user account:

    su - hadoop
  2. Create a new file for demonstration purposes:

    echo "Hello, Hadoop FS Shell chmod" > /home/hadoop/demo_file.txt
  3. Put the file to HDFS:

    hdfs dfs -put /home/hadoop/demo_file.txt /
  4. Set permissions for the demo_file.txt:

    hdfs dfs -chmod 644 /demo_file.txt

With 644 as the permission mode, it means:

  • The owner of the file (user) has read (4), write (2), and no execute (0) permissions.
  • The group (group) has read (4) permissions only.
  • Others (others) have read (4) permissions only.

So, the command hdfs dfs -chmod 644 /demo_file.txt will set the permissions of the file /demo_file.txt in HDFS to read and write for the owner, read-only for the group, and read-only for others.

Modifying Permissions

In this step, you will modify the permissions of the existing file using the chmod command.

  1. Let's change the permissions of the demo_file.txt to read-only for the group and others:

    hdfs dfs -chmod 444 /demo_file.txt
  2. Verify the updated permissions of the file:

    hdfs dfs -ls /demo_file.txt

In summary, we can see a file with permission mode 444 allows read access to the owner, group, and others but does not allow write or execute access to anyone.

Summary

In this lab, we delved into the world of setting and modifying permissions using Hadoop's FS Shell chmod command within a futuristic underground data storage infrastructure.

By following the step-by-step instructions, learners can gain hands-on experience in managing permissions effectively in a Hadoop environment. This lab aims to provide a practical understanding of permission settings for Hadoop HDFS operations.

Other Hadoop Tutorials you may like