Introduction
As I continue my RHCSA journey with the 30-day Linux challenge. Today’s focus is one of those everyday essentials that saves time, boosts efficiency and solves the age-old question: "Where did that file go?"
Let’s talk about file searching in Linux using the powerful trio: find
, locate
and which
.
Index
🔍 What Are These Commands?
1. find
A versatile and powerful command to search for files and directories in real time.
find /home/sana -name "report.txt"
This searches for a file named report.txt
starting from /home/sana
.
2. locate
Faster than find
because it searches through a prebuilt database.
locate report.txt
Bonus tip: Update the database with sudo updatedb
before using.
3. which
Used to locate the executable path of a command.
which python3
It tells you where python3
is installed on your system.
💡 Real Life Use Cases
- ✅ Sysadmin Troubleshooting – Find misplaced logs or config files in seconds.
- ✅ Development Setup – Locate compilers, interpreters or toolchains installed.
- ✅ Audits & Backups – Combine
find
withmtime
to identify old files for cleanup or backup.
🚀 Pro Tips
- Search files by modification time:
find . -mtime -2
(Finds files modified in the last 2 days)
- Combine
find
withexec
:
find . -type f -name "*.log" -exec rm {} \;
(Deletes all .log
files from the current directory down)
- Want blazing fast results? Use
locate
but make sure to runupdatedb
first.
🛠️ Industrial Insight
In production environments, time matters.
Searching for the right config file or script quickly can reduce downtime.
Advanced users often combine these tools in automation scripts for health checks or audits.
✅ Quick Summary
Command | Best For |
---|---|
find |
Deep, real-time file searches with powerful filters |
locate |
Super-fast searches with a prebuilt index |
which |
Finding executables in your system path |
Mastering these tools means you’ll never lose track of a file again.
I'd love to hear your thoughts, insights or experiences with Linux. Feel free to share and join the conversation [ Connect with me on LinkedIn www.linkedin.com/in/techwithsana ]💜
#30dayslinuxchallenge #redhat #networking #cloudcomputing #cloudengineer #cloudarchitect #cloud #RHCSA #RHCE #RHEL #WomeninTech #Technology
Top comments (0)