Master Advanced HDFS Commands for efficient management of distributed systems. Explore fsck for health checks, advanced file operations, handling DataNode failures, and managing permissions and ownership directly through the command line interface (CLI).
1. Using fsck Command to Check HDFS Health
What is the purpose of the hdfs fsck command?
A) To check DataNode configurations
B) To perform HDFS health checks
C) To replicate blocks
D) To delete corrupted files
Which option with fsck displays detailed block information?
A) -move
B) -files
C) -blocks
D) -replication
What does the hdfs fsck command report?
A) Metadata and user access details
B) File system status and block health
C) NameNode uptime
D) DataNode performance
How can you use fsck to fix under-replicated blocks?
A) By running hdfs fsck -fix
B) By restarting NameNode
C) By enabling dynamic replication
D) By increasing the replication factor manually
What does the CORRUPT status in fsck output indicate?
A) Replication is too high
B) Block files are missing or inaccessible
C) DataNode is overloaded
D) File permissions are incorrect
How do you exclude non-critical errors in the fsck report?
A) Use -ignore
B) Use -status
C) Use -locations
D) Use -show
2. Advanced HDFS File Management
Which command moves a file within HDFS?
A) hdfs dfs -moveToLocal
B) hdfs dfs -mv
C) hdfs dfs -cp
D) hdfs dfs -rm
What does hdfs dfs -copyToLocal do?
A) Copies files from HDFS to the local filesystem
B) Copies files between HDFS directories
C) Moves files from HDFS to local storage
D) Creates backup copies in HDFS
How can you upload files from the local system to HDFS?
A) hdfs dfs -moveFromLocal
B) hdfs dfs -put
C) hdfs dfs -copyToLocal
D) hdfs dfs -fetch
Which command is used to rename a file in HDFS?
A) hdfs dfs -rename
B) hdfs dfs -mv
C) hdfs dfs -cp
D) hdfs dfs -edit
What is the difference between -put and -copyFromLocal?
A) -put requires HDFS privileges, -copyFromLocal does not
B) -put overwrites by default, -copyFromLocal does not
C) Both commands are identical
D) -put is faster than -copyFromLocal
How do you recursively copy a directory in HDFS?
A) hdfs dfs -copyDir
B) hdfs dfs -cp
C) hdfs dfs -cp -r
D) hdfs dfs -recursive
What happens when you run hdfs dfs -rmr on a directory?
A) Deletes only the specified files
B) Deletes the directory recursively
C) Archives the directory
D) Deletes directory metadata
Which option allows you to append data to an existing HDFS file?
A) -appendToFile
B) -addToFile
C) -editFile
D) -extendFile
How do you view the contents of an HDFS file without downloading it?
A) hdfs dfs -read
B) hdfs dfs -cat
C) hdfs dfs -head
D) hdfs dfs -open
3. DataNode Failures and Recovery Procedures
What happens to data stored on a failed DataNode?
A) It is automatically deleted
B) It is replicated to other nodes
C) It becomes inaccessible permanently
D) It is moved to a backup directory
Which HDFS process ensures data availability during DataNode failures?
A) Automatic failover
B) DataNode rebalancing
C) Block replication
D) SecondaryNameNode synchronization
How can you manually decommission a DataNode?
A) By updating the hdfs-site.xml file
B) By restarting the NameNode
C) By disabling dynamic replication
D) By stopping the SecondaryNameNode
What command is used to check the status of DataNodes?
A) hdfs dfsadmin -report
B) hdfs dfs -ls
C) hdfs fsck -nodes
D) hdfs admin -datanode
How does HDFS handle a full DataNode disk?
A) DataNode is shut down
B) Blocks are moved to other nodes
C) Replication factor is increased
D) Data is deleted from the node
What is the first step in recovering a failed DataNode?
A) Restart the NameNode
B) Restart the DataNode service
C) Delete corrupted blocks
D) Decrease replication factor
What does HDFS safe mode enable during failure recovery?
A) Enables block edits
B) Disables write operations temporarily
C) Enables data movement
D) Resets DataNode logs
4. Managing Permissions and Ownership via CLI
Which command changes the ownership of an HDFS file?
A) hdfs dfs -setOwner
B) hdfs dfs -chown
C) hdfs dfs -perm
D) hdfs dfs -own
How do you modify the permissions of an HDFS file?
A) hdfs dfs -chmod
B) hdfs dfs -setPerm
C) hdfs dfs -chperm
D) hdfs dfs -modPerm
What does the rwx format in HDFS file permissions mean?
A) Read, write, execute
B) Replication, write, execute
C) Read, write, delete
D) Read, write, copy
Which user can modify all files in HDFS?
A) The DataNode admin
B) The HDFS superuser
C) The NameNode user
D) Any authorized user
What does the command hdfs dfs -ls -R do?
A) Lists all files recursively
B) Displays file ownerships only
C) Shows hidden files in HDFS
D) Lists files sorted by replication
How do you ensure only specific users can access a file in HDFS?
A) By changing file ownership
B) By setting appropriate permissions
C) By moving the file to a private directory
D) By encrypting the file
What does the sticky bit in HDFS permissions allow?
A) Only the file owner can delete or modify files in a directory
B) Files are replicated to specific nodes
C) Blocks are never moved between nodes
D) Files are locked for all users
How do you verify HDFS file ownership?
A) hdfs dfs -checkOwner
B) hdfs dfs -ls
C) hdfs dfs -viewOwner
D) hdfs dfs -stat
Answers
Qno
Answer
1
B) To perform HDFS health checks
2
C) -blocks
3
B) File system status and block health
4
A) By running hdfs fsck -fix
5
B) Block files are missing or inaccessible
6
A) Use -ignore
7
B) hdfs dfs -mv
8
A) Copies files from HDFS to the local filesystem
9
B) hdfs dfs -put
10
B) hdfs dfs -mv
11
B) -put overwrites by default, -copyFromLocal does not
12
C) hdfs dfs -cp -r
13
B) Deletes the directory recursively
14
A) -appendToFile
15
B) hdfs dfs -cat
16
B) It is replicated to other nodes
17
C) Block replication
18
A) By updating the hdfs-site.xml file
19
A) hdfs dfsadmin -report
20
B) Blocks are moved to other nodes
21
B) Restart the DataNode service
22
B) Disables write operations temporarily
23
B) hdfs dfs -chown
24
A) hdfs dfs -chmod
25
A) Read, write, execute
26
B) The HDFS superuser
27
A) Lists all files recursively
28
B) By setting appropriate permissions
29
A) Only the file owner can delete or modify files in a directory