Setting Permissions
In this step, you will learn how to set permissions using the chmod
command in Hadoop's FS Shell.
-
Switch to the hadoop
user account:
su - hadoop
-
Create a new file for demonstration purposes:
echo "Hello, Hadoop FS Shell chmod" > /home/hadoop/demo_file.txt
-
Put the file to HDFS:
hdfs dfs -put /home/hadoop/demo_file.txt /
-
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.