010-160 Linux Filesystem & File Management 2 — Questions and Answers
Question 1: Which command displays the disk space usage of files and directories?
- df
- du (Correct answer)
- ls -s
- stat
Correct answer: du
The `du` (disk usage) command shows how much disk space files and directories consume.
Question 2: What does the `df -h` command display?
- Hidden files on all filesystems
- Disk free space in human-readable format (Correct answer)
- Directory file counts with headers
- Default filesystem hierarchy
Correct answer: Disk free space in human-readable format
`df -h` shows disk free space with sizes in human-readable units like KB, MB, and GB.
Question 3: Which directory typically contains temporary files that are deleted on reboot?
- /var/tmp
- /tmp (Correct answer)
- /run/tmp
- /home/tmp
Correct answer: /tmp
/tmp is the standard temporary directory whose contents are typically cleared on system reboot.
Question 4: What is the purpose of the `find` command's `-name` option?
- Rename files matching a pattern
- Search for files by their filename (Correct answer)
- Display the full path name of found files
- Set a new name for the search result
Correct answer: Search for files by their filename
The `-name` option in `find` searches for files whose names match the given pattern.
Question 5: Which command would you use to create a symbolic link named `link.txt` pointing to `original.txt`?
- ln original.txt link.txt
- ln -s original.txt link.txt (Correct answer)
- link original.txt link.txt
- cp -l original.txt link.txt
Correct answer: ln -s original.txt link.txt
`ln -s` creates a symbolic (soft) link; without -s it creates a hard link.
Question 6: What does the `file` command do in Linux?
- Creates a new empty file
- Determines the type of a file based on its content (Correct answer)
- Lists files in the current directory
- Moves a file to a new location
Correct answer: Determines the type of a file based on its content
The `file` command examines a file's contents and reports its type (e.g., ASCII text, ELF binary, JPEG image).
Question 7: Which of the following is the correct path to a user's home directory for a user named 'alice'?
- /root/alice
- /home/alice (Correct answer)
- /usr/alice
- /etc/alice
Correct answer: /home/alice
On Linux, regular user home directories are conventionally located under /home/<username>.
Which command displays the disk space usage of files and directories?