Linux File System Navigation 4 — Questions and Answers
Question 1: Which command finds all files named `config.txt` starting from the root directory?
- find / -name config.txt (Correct answer)
- locate / config.txt
- search -name config.txt /
- grep -r config.txt /
Correct answer: find / -name config.txt
`find / -name config.txt` recursively searches from `/` for files exactly matching that name.
Question 2: What does the `realpath` command return?
- The resolved absolute path with all symlinks expanded (Correct answer)
- The relative path from the current directory
- The inode number of a file
- A list of real (non-symbolic) files
Correct answer: The resolved absolute path with all symlinks expanded
`realpath` canonicalizes a path by resolving all symbolic links and `.` / `..` components.
Question 3: Which directory stores temporary files that are cleared on reboot on systemd-based systems?
- /tmp (Correct answer)
- /var/tmp
- /run/tmp
- /cache/tmp
Correct answer: /tmp
On systemd systems, `/tmp` is typically a tmpfs mount cleared at boot, unlike `/var/tmp` which persists.
Question 4: What output does `ls -la /` show that `ls -l /` does not?
- Hidden entries like `.` and `..` (Correct answer)
- File sizes in bytes
- Inode numbers
- Hard link counts
Correct answer: Hidden entries like `.` and `..`
The `-a` flag includes entries starting with `.`, such as the `.` (current) and `..` (parent) directory entries.
Question 5: Which command would you use to navigate directly to `/etc/nginx/conf.d` regardless of where you currently are?
- cd /etc/nginx/conf.d (Correct answer)
- cd etc/nginx/conf.d
- cd ~/etc/nginx/conf.d
- cd ./etc/nginx/conf.d
Correct answer: cd /etc/nginx/conf.d
An absolute path starting with `/` navigates directly from root regardless of the current directory.
Question 6: What does `ls -i` display alongside file names?
- Inode numbers (Correct answer)
- File permissions in octal
- Index of file size
- Inbound link count
Correct answer: Inode numbers
The `-i` flag makes `ls` print the inode number of each file before its name.
Question 7: Which command shows disk usage of each subdirectory one level deep inside `/home`?
- du -h --max-depth=1 /home (Correct answer)
- df -h /home/*
- ls -sh /home/*/
- du /home -depth 1
Correct answer: du -h --max-depth=1 /home
`du -h --max-depth=1 /home` reports human-readable disk usage for each immediate subdirectory of `/home`.
Which command finds all files named `config.txt` starting from the root directory?