U.S. Independence Day Deal! Unlock 25% OFF Today – Limited-Time Offer - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

LPI 010-160 Exam - Topic 3 Question 69 Discussion

Which of the following commands will search for the file foo.txt under the directory /home?
D) find /home --name foo.txt
A) search /home --file foo.txt
B) search /home foo. txt
C) find /home -- file foo.txt
E) find /home foo.txt

LPI 010-160 Exam - Topic 3 Question 69 Discussion

Actual exam question for LPI's 010-160 exam
Question #: 69
Topic #: 3
[All 010-160 Questions]

Which of the following commands will search for the file foo.txt under the directory /home?

Show Suggested Answer Hide Answer
Suggested Answer: D

The correct command to search for the file foo.txt under the directory /home is find /home --name foo.txt. This command uses the find command, which is used to search for files and directories that match certain criteria. The first argument, /home, specifies the starting point of the search. The second argument, -name, indicates that the search is based on the name of the file or directory. The third argument, foo.txt, is the name of the file to be searched for. The find command will recursively search all the subdirectories under /home and print the path of any file or directory that matches the name foo.txt.

The other commands are incorrect for various reasons:

A . search /home --file foo.txt is incorrect because there is no such command as search in Linux. The correct command for searching files and directories is find.

B . search /home foo.txt is incorrect because, as mentioned above, there is no search command in Linux. Also, this command does not use any option to specify the search criteria, such as -name, -type, -size, etc.

C . find /home -- file foo.txt is incorrect because the option -file is not valid. The correct option for specifying the type of file or directory is -type, followed by a letter that indicates the type, such as f for regular file, d for directory, l for symbolic link, etc. For example, find /home -type f -name foo.txt would search for a regular file named foo.txt under /home.

E . find /home foo.txt is incorrect because this command does not use any option to specify the search criteria, such as -name, -type, -size, etc. This command will search for any file or directory that has foo.txt as part of its name, not exactly as its name. For example, this command will also match a file named barfoo.txt or a directory named foo.txt.bak.


Contribute your Thoughts:

0/2000 characters

Currently there are no comments in this discussion, be the first to comment!


Save Cancel