Linux Essentials (010-160) — Question 6
Which of the following commands will search for the file foo.txt under the directory /home?
Answer options
- A. search /home -file foo.txt
- B. search /home foo. txt
- C. find /home - file foo.txt
- D. find /home -name foo.txt
- E. find /home foo.txt
Correct answer: D
Explanation
The correct command is D, 'find /home -name foo.txt', which accurately searches for a file by its name within the specified directory. Options A and C are incorrect due to the misuse of the command 'search' and incorrect syntax. Option B has a space in 'foo. txt', which would make it invalid, while option E lacks the '-name' flag, which is essential for a name-based search.