Introduction
Imagine yourself in a futuristic technology lab where you are playing the role of a quantum physicist. In this lab, you have been tasked with managing data in a distributed environment using Hadoop HDFS. Your goal is to learn and practice the usage of the "FS Shell chgrp" command to change the group ownership of files or directories.
Change Group Ownership of a File
In this step, you will change the group ownership of a file named example.txt to a different group called newgroup.
Switch to the
hadoopuser in the terminal using :su - hadoopCreate a text file named
example.txtin the directory.echo "Hello World" > example.txtPut the
example.txtfile into the Hadoop file system:hadoop fs -put example.txt /user/hadoop/Run the following command to list the group ownership of the file:
hadoop fs -ls /user/hadoop/to see the group ownership of the file like this:
-rw-r--r-- 1 hadoop supergroup 12 2024-03-19 20:53 /user/hadoop/example.txtChange the group ownership of the file to
newgroup.hadoop fs -chgrp newgroup /user/hadoop/example.txtRun the following command to list the group ownership of the file:
hadoop fs -ls /user/hadoop/to see the group ownership of the file like this:
-rw-r--r-- 1 hadoop newgroup 12 2024-03-19 20:53 /user/hadoop/example.txt
Change Group Ownership of a Directory
In this step, you will practice changing the group ownership of a directory named data to a different group called analytics.
Create a directory named
datain the/user/hadoopdirectory.hadoop fs -mkdir /user/hadoop/dataRun the following command to list the created directory:
hadoop fs -ls /user/hadoop/to see the directory like this:
drwxr-xr-x - hadoop supergroup 0 2024-03-19 20:57 /user/hadoop/dataChange the group ownership of the directory to
analytics.hadoop fs -chgrp analytics /user/hadoop/dataRun the following command to list the group ownership of the directory:
hadoop fs -ls /user/hadoop/to see the group ownership of the directory like this:
drwxr-xr-x - hadoop analytics 0 2024-03-19 20:57 /user/hadoop/data
Summary
In this lab, you were able to explore and practice using the Hadoop FS Shell chgrp command to change group ownership of files and directories in a Hadoop distributed file system. By following the step-by-step instructions and checkers provided, you gained hands-on experience in managing data permissions in a Hadoop environment.



