Introduction
In this lab, we will explore the Hadoop HDFS skill point "FS Shell stat" within the context of a scenario set in the legendary tale of a sunken shipwreck treasure cove. Imagine a scenario where the undiscovered treasures of a sunken ship are said to be buried deep within the ocean floor of the Treasure Cove. You play the role of a renowned narrator of this treasure hunting legend whose task is to guide explorers to uncover the hidden riches.
Exploring FS Shell stat
In this step, we will delve into the hadoop fs -stat command to gather detailed information about a specific file in Hadoop HDFS.
switch to the
hadoopuser:su - hadoopcreate a file named
treasure.txtin the current directory:vim treasure.txtthe content in
treasure.txtis:hello worldput the
treasure.txtfile into the Hadoop file system:hadoop fs -put treasure.txt /user/hadoop/Use the following command to display the attributes of a file named
treasure.txtin the Hadoop file system:hadoop fs -stat %g-%F-%b-%y-%Y-%o /user/hadoop/treasure.txtthe parameters in the command are:
%g: Group name of owner %F: File type %b: Length in bytes %y: Modification timestamp %Y: Access timestamp %o: Block sizeThe output will provide information such as file permissions, file type, modification time, access time, and block size. like this:
supergroup-regular file-12-2024-03-08 12:42:00-1709901720659-134217728
Analyzing File Permissions
In this step, we will focus on understanding and analyzing the file permissions using the hadoop fs -stat command.
Execute the following command to view the file permissions of the
treasure.txtfile:hadoop fs -stat %F-%A /user/hadoop/treasure.txtthe parameters in the command are:
%F: File type %A: File permissionsThe output will display the file type and permissions associated with the file. like this:
regular file-rw-r--r--
Summary
In this lab, we explored the hadoop fs -stat command within the Hadoop HDFS environment to retrieve detailed file information. By following the step-by-step guide, users can gain a better understanding of how to utilize this command for file attribute analysis and permission verification in Hadoop. This lab aims to provide hands-on experience for beginners to familiarize themselves with FS Shell stat operations in Hadoop.



