0
0
Linux CLIscripting~5 mins

locate for fast filename search in Linux CLI - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the locate command in Linux?
The locate command quickly finds files by name using a pre-built database, making searches much faster than scanning the whole disk each time.
Click to reveal answer
beginner
How does locate find files so quickly compared to find?
locate uses a database that stores file paths updated regularly, so it searches this database instead of scanning the disk live like find does.
Click to reveal answer
beginner
What command updates the locate database?
The updatedb command refreshes the database that locate uses to find files.
Click to reveal answer
beginner
How do you search for all files containing 'report' in their name using locate?
Run locate report to list all files and paths that include 'report' anywhere in their name or path.
Click to reveal answer
beginner
Why might locate not find very new files?
Because locate searches a database updated periodically, very new files created after the last update won't appear until the database is refreshed with updatedb.
Click to reveal answer
What does the locate command use to find files quickly?
AReal-time scanning of the entire disk
BA pre-built database of file paths
CUser input to guess file locations
DInternet search engines
Which command updates the database used by locate?
Arefreshdb
Blocate --update
Cfind
Dupdatedb
If you just created a file and locate does not find it, what should you do?
ARun <code>updatedb</code> to update the database
BRestart the computer
CUse <code>find</code> instead
DWait for 24 hours
Which command is slower but always up-to-date for searching files?
Afind
Blocate
Cupdatedb
Dgrep
What will locate report do?
ACreate a file named 'report'
BDelete files named 'report'
CList all files with 'report' in their path or name
DUpdate the locate database
Explain how the locate command works and why it is faster than find.
Think about how searching a list is faster than searching the whole disk every time.
You got /4 concepts.
    Describe the steps to find a newly created file using locate.
    Remember the database needs to know about new files first.
    You got /3 concepts.