MCQs on Basic HDFS Commands | Hadoop HDFS

Learn about Hadoop FS shell commands, file operations (ls, cp, mv, rm), file permissions, and managing files in HDFS. This set of 30 MCQs will sharpen your HDFS command knowledge.


Introduction to Hadoop FS Shell (Questions 1-8)

  1. What does the Hadoop FS Shell command allow you to do?
    a) View files in a local file system
    b) Perform file operations in Hadoop HDFS
    c) Monitor network traffic
    d) Set permissions for files
  2. Which command is used to interact with HDFS through the Hadoop FS shell?
    a) hadoop fs -ls
    b) hadoop shell -fs
    c) hdfs -cmd
    d) hadoop -fs
  3. In Hadoop, what is the main purpose of the FS Shell?
    a) Manage hardware resources
    b) Perform file system operations on HDFS
    c) Run Java applications
    d) Manage data processing tasks
  4. Which of the following does the command hadoop fs -cat do?
    a) Creates a file
    b) Displays the contents of a file
    c) Deletes a file
    d) Moves a file
  5. What is the use of the hadoop fs -put command?
    a) Deletes files from HDFS
    b) Copies a local file to HDFS
    c) Creates directories in HDFS
    d) Lists files in HDFS
  6. How do you view the help documentation for a specific FS command in Hadoop?
    a) hadoop fs -help <command>
    b) hadoop fs -manual
    c) hdfs fs -info
    d) hadoop fs -guide
  7. What does the command hadoop fs -du display?
    a) Directory contents
    b) Disk usage of files and directories
    c) File permissions
    d) Ownership details
  8. How would you list files and directories in HDFS using the Hadoop FS Shell?
    a) hadoop fs -ls
    b) hadoop fs -list
    c) hdfs -ls
    d) hadoop fs -dir

Commands for File Operations (Questions 9-16)

  1. Which command in Hadoop is used to copy files from local to HDFS?
    a) hadoop fs -move
    b) hadoop fs -copyFromLocal
    c) hadoop fs -putLocal
    d) hadoop fs -transfer
  2. What does the hadoop fs -cp command do?
    a) Copies files from one HDFS location to another
    b) Creates directories in HDFS
    c) Copies local files to HDFS
    d) Changes file ownership
  3. How would you move a file from one directory to another in HDFS?
    a) hadoop fs -moveFromLocal
    b) hadoop fs -move
    c) hadoop fs -mv
    d) hdfs fs -move
  4. Which command removes files or directories in HDFS?
    a) hadoop fs -delete
    b) hadoop fs -rm
    c) hadoop fs -rmdir
    d) hdfs fs -remove
  5. What happens if you try to use hadoop fs -rm on a non-empty directory?
    a) It removes all contents recursively
    b) It will display an error and not delete the directory
    c) It skips the directory
    d) It moves the contents to trash
  6. What is the difference between hadoop fs -rm and hadoop fs -rmr?
    a) -rmr removes directories recursively, -rm does not
    b) -rm removes directories, -rmr only removes files
    c) -rm is for files, -rmr is for directories
    d) There is no difference
  7. Which of the following commands copies an HDFS file to the local file system?
    a) hadoop fs -copyToLocal
    b) hadoop fs -download
    c) hadoop fs -localCopy
    d) hadoop fs -moveToLocal
  8. How do you rename a file or directory in HDFS?
    a) hadoop fs -rename
    b) hadoop fs -move
    c) hadoop fs -renameFile
    d) hadoop fs -mv

File Permissions and Ownership (Questions 17-22)

  1. Which command is used to change the owner of a file in HDFS?
    a) hadoop fs -chown
    b) hadoop fs -chmod
    c) hadoop fs -setOwner
    d) hdfs fs -chown
  2. How do you modify file permissions in HDFS?
    a) hadoop fs -changeMode
    b) hadoop fs -chmod
    c) hadoop fs -permission
    d) hdfs fs -chmod
  3. What does the hadoop fs -chmod 755 command do to a file in HDFS?
    a) Grants full permissions to the owner, and read and execute permissions to others
    b) Revokes all permissions
    c) Grants read and write permissions to the owner
    d) Sets execute permission for all users
  4. Which command would you use to check the permissions of a file in HDFS?
    a) hadoop fs -ls
    b) hadoop fs -status
    c) hadoop fs -perm
    d) hadoop fs -permStatus
  5. What does the hadoop fs -chown command modify in HDFS?
    a) File content
    b) File owner and group
    c) File permissions
    d) File path
  6. In Hadoop, which part of the file system determines who can read, write, and execute a file?
    a) HDFS block size
    b) File permissions
    c) File metadata
    d) File system root

Viewing and Managing Files in HDFS (Questions 23-30)

  1. Which command in Hadoop FS shell displays detailed information about files in HDFS?
    a) hadoop fs -info
    b) hadoop fs -stat
    c) hadoop fs -details
    d) hadoop fs -fileinfo
  2. Which command lists the directory content in HDFS with detailed information?
    a) hadoop fs -dir
    b) hadoop fs -ls -R
    c) hadoop fs -ls -l
    d) hadoop fs -info -list
  3. What does the hadoop fs -tail command do?
    a) Displays the first few lines of a file
    b) Displays the last part of a file
    c) Deletes the last part of a file
    d) Renames the last file in the directory
  4. What would you use hadoop fs -du -s for in HDFS?
    a) Display the disk usage of a specific file
    b) Display the total disk usage of a directory
    c) Display the usage of a file or directory recursively
    d) Display the file owner and permissions
  5. How would you view the contents of a file stored in HDFS?
    a) hadoop fs -view
    b) hadoop fs -cat
    c) hadoop fs -read
    d) hadoop fs -list
  6. Which command shows the size of a file in HDFS?
    a) hadoop fs -size
    b) hadoop fs -du
    c) hadoop fs -df
    d) hadoop fs -length
  7. What command allows you to move a file in HDFS?
    a) hadoop fs -move
    b) hadoop fs -rename
    c) hadoop fs -mv
    d) hadoop fs -copy
  8. Which of the following commands will recursively delete a directory and all its contents in HDFS?
    a) hadoop fs -rm
    b) hadoop fs -rm -r
    c) hadoop fs -delete -r
    d) hadoop fs -del -r

Answer Key

QNoAnswer (Option with Text)
1b) Perform file operations on HDFS
2a) hadoop fs -ls
3b) Perform file system operations on HDFS
4b) Displays the contents of a file
5b) Copies a local file to HDFS
6a) hadoop fs -help <command>
7b) Disk usage of files and directories
8a) hadoop fs -ls
9b) hadoop fs -copyFromLocal
10a) Copies files from one HDFS location to another
11c) hadoop fs -mv
12b) hadoop fs -rm
13b) It will display an error and not delete the directory
14a) -rmr removes directories recursively, -rm does not
15a) hadoop fs -copyToLocal
16d) hadoop fs -mv
17a) hadoop fs -chown
18b) hadoop fs -chmod
19a) Grants full permissions to the owner, and read and execute permissions to others
20a) hadoop fs -ls
21b) File owner and group
22b) File permissions
23b) hadoop fs -stat
24c) hadoop fs -ls -l
25b) Displays the last part of a file
26b) Display the total disk usage of a directory
27b) hadoop fs -cat
28b) hadoop fs -du
29c) hadoop fs -mv
30b) hadoop fs -rm -r

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top