Challenge - 5 Problems
Locate Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
Output of locate command with a simple filename
What is the output of the following command if the file
notes.txt exists in /home/user/documents and /var/log directories?locate notes.txtLinux CLI
locate notes.txt
Attempts:
2 left
💡 Hint
The locate command lists all paths containing the filename quickly from its database.
✗ Incorrect
The locate command searches its database and lists all matching file paths. Since notes.txt exists in two directories, both paths are shown.
💻 Command Output
intermediate1:30remaining
Effect of updating locate database
What happens if you create a new file
/tmp/testfile.txt and immediately run locate testfile.txt without updating the database?Linux CLI
touch /tmp/testfile.txt locate testfile.txt
Attempts:
2 left
💡 Hint
locate uses a database updated periodically, not real-time file system scanning.
✗ Incorrect
The locate database is updated by the updatedb command, usually run daily. New files won't appear until the database updates.
📝 Syntax
advanced2:00remaining
Correct syntax to search for files ending with .log using locate
Which command correctly finds all files ending with
.log using locate?Attempts:
2 left
💡 Hint
Use the -r option to enable regex search in locate.
✗ Incorrect
The -r option allows locate to interpret the pattern as a regular expression. The pattern '\.log$' matches files ending with .log.
🔧 Debug
advanced1:30remaining
Why does locate not find a recently created file?
You created a file
/home/user/newfile.txt but locate newfile.txt returns no results. What is the most likely reason?Attempts:
2 left
💡 Hint
locate uses a database updated periodically, not real-time scanning.
✗ Incorrect
locate relies on a database updated by updatedb. New files won't appear until the database is refreshed.
🚀 Application
expert2:30remaining
Automate locate database update and search
You want to write a script that updates the locate database and then searches for files named
report.csv. Which script snippet correctly does this?Attempts:
2 left
💡 Hint
The database must update before searching to include new files.
✗ Incorrect
The script runs updatedb first with sudo to refresh the database, then runs locate to find the file.