locate: Fast — but Only as Fresh as Its Index
EasyLinux Fundamentals10-15 minlocate answers 'where is that file?' instantly — because it searches a prebuilt INDEX, not the disk. The catch: files created after the last index build are invisible to it. Feel that tradeoff for real:
1. locate blueprint-alpha — it's indexed, so it answers instantly. Save the result (the full path locate prints) to /root/answers/old.txt.
2. Now try locate needle-omega. Nothing! The file exists somewhere under /root/warehouse (prove it with find /root/warehouse -name 'needle*') but it was created AFTER the index was built. Rebuild the index with updatedb, locate it again, and save the result to /root/answers/fresh.txt.
That's the whole locate-vs-find decision: locate = instant but possibly stale; find = always current but walks the disk.
- Save the indexed locate hit for blueprint-alpha to old.txt
- Rebuild the index with updatedb, then locate needle-omega into fresh.txt
Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.
