Lab2_BigData-HDFSp
Lab2_BigData-HDFSp
HDFS (Manipulation)
Objective:
The objective of this lab is to provide hands-on experience with Hadoop HDFS (Hadoop Distributed File
System) command-line operations. Students will learn how to navigate, manipulate files and directories, and
perform common tasks using HDFS commands.
Prerequisites:
− Basic understanding of the Hadoop ecosystem.
− Hadoop installation with HDFS configured.
Note :
− Replace <your_username> with your actual Hadoop username.
− Adjust paths based on your specific HDFS setup.
− Ensure that you have the necessary permissions to perform the operations.
Lab Tasks:
2. Create Directories:
Create a directory named "lab_data" in HDFS:
hdfs dfs -mkdir /user/<your_username>/lab_data
Page 1|2
3. Upload Data:
Upload a local file sample.txt to the "lab_data" directory in HDFS:
hdfs dfs -put /local/path/sample.txt/user/<your_username>/lab_data/
4. List Contents:
List the contents of the "lab_data" directory:
hdfs dfs -ls /user/<your_username>/lab_data
5. Copy Data:
Create a copy of "sample.txt" named "sample_copy.txt" in the same directory:
hdfs dfs -cp /user/<your_username>/lab_data/sample.txt
/user/<your_username>/lab_data/sample_copy.txt
sample file:
Page 2|2
Viewing the content of "sample.txt" in HDFS:
7. Move Data:
Move "sample_copy.txt" to a new directory named "backup":
hdfs dfs -mv /user/<your_username>/lab_data/sample_copy.txt
/user/<your_username>/backup/
8. Remove Data:
Remove the "sample.txt" file from HDFS:
hdfs dfs -rm /user/<your_username>/lab_data/sample.txt
9. Recursive Remove:
Remove the entire "backup" directory and its contents:
hdfs dfs -rm -r /user/<your_username>/backup
Page 3|2
10. Check Disk Usage:
Check the disk usage of the HDFS directory:
hdfs dfs -du -h /user/<your_username>
Monitoring
http://localhost:9870
Page 4|2