Lädt...

🔧 Master the Find Command: Stop Searching Manually in Linux


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

A few years ago, I wasted 30 minutes looking for a misplaced log file—scrolling through directories, opening files manually, and running random ls commands.

Then, I learned how to use find properly—and found the file in 5 seconds.

If you are still clicking through directories or using slow GUI searches, it’s time to master the find command. This guide will eliminate manual searching forever with real-world examples, not just a list of flags.

Need a quick-reference guide for Bash scripting?

👉 Get the Bash Cheat Book for $3.99

1. Stop Searching by Hand: Find Any File Instantly

Most Common Manual Search Mistake:

Manually navigating directories or using ls to search for a file:

ls -lR /home/user | grep "report.pdf"  # ❌ Slow and inefficient

✅ The Fix: Use find for Instant Search

find /home/user -name "report.pdf"

🔹 Why it's better: Works even if you don’t remember the exact location.

🔹 Bonus: Make it case-insensitive:

find /home/user -iname "report.pdf"

2. Searching by File Type: Don't Get Unnecessary Results

Instead of listing everything, filter results by type.

Find Only Directories

find /home/user -type d -name "projects"

Find Only Files

find /var/log -type f -name "*.log"

🔹 Why it's useful: Stops wasting time sifting through irrelevant results.

3. Finding Large Files Eating Up Space

Instead of guessing which files are wasting disk space, use find to locate big offenders instantly.

Find Files Larger Than 500MB

find /home -type f -size +500M

Find Files Between 50MB and 100MB

find /home -type f -size +50M -size -100M

🔹 Why it’s useful: Helps free up storage without digging through directories manually.

4. Find Recently Modified Files for Debugging

Finding recently edited files helps track down issues fast.

Find Files Modified in the Last 7 Days

find /var/log -type f -mtime -7

Find Files Modified More Than 30 Days Ago

find /var/log -type f -mtime +30

Find Files Modified in the Last 10 Minutes

find /var/log -type f -mmin -10

🔹 Why it's useful: Essential for debugging recent system changes.

5. Cleaning Up: Find and Delete Files in One Command

Stop manually deleting files one by one.

Delete All .tmp Files in /tmp

find /tmp -type f -name "*.tmp" -delete

🚨 Test first before deleting:

find /tmp -type f -name "*.tmp" -print

🔹 Why it’s useful: Automates temporary file cleanup.

6. Batch Processing: Running Commands on Found Files

You can use find to automate tasks across multiple files.

Change Ownership of All .log Files

find /var/log -type f -name "*.log" -exec chown user:user {} \;

Move All .jpg Files to Another Directory

find /home/user/Pictures -type f -name "*.jpg" -exec mv {} /backup/images/ \;

🚀 Pro Tip: If your command needs multiple files, use + instead of \; for better performance:

find /home/user/Pictures -type f -name "*.jpg" -exec mv {} /backup/images/ +

🔹 Why it's useful: Great for bulk renaming, moving, or modifying files.

7. Searching With Logical Operators: Combine Multiple Criteria

Find .log OR .txt Files

find /var/log -type f \( -name "*.log" -o -name "*.txt" \)

Find Files Modified in the Last 7 Days AND Larger Than 1MB

find /home -type f -mtime -7 -a -size +1M

🔹 Why it's useful: Refines searches to only return exactly what you need.

8. Finding Hidden Files (.* Dotfiles)

List All Hidden Files in a Directory

find /home/user -type f -name ".*"

🔹 Why it’s useful: Quickly find dotfiles like .bashrc, .gitconfig, etc.

9. Searching for Files by Permission Settings

Find Files That Are World-Readable (644)

find /home -type f -perm 644

Find Files That Are Executable (755)

find /usr/bin -type f -perm 755

🔹 Why it's useful: Helps detect misconfigured permissions that could be security risks.

10. Finding Files Without a Certain Extension

Find All Files Except .log

find /var/log -type f -not -name "*.log"

🔹 Why it's useful: When you need to exclude certain file types from your search.

Final Thoughts: Stop Searching Manually

Mastering just a few find tricks will eliminate wasted time spent manually looking for files.

Quick Recap:

Find files by name, type, and size

Search by modification time to track changes

Use -exec and -delete for batch processing

Want a Structured Bash Reference?

If you need a Easy to Read Bash guide with real-world scripts, check out my Bash Cheat Sheet:

👉 Download the Bash Cheat Book for just $3.99

What’s Inside?

✔️ Essential Bash commands for automation

✔️ File handling, process management, and troubleshooting tips

✔️ Formatted PDF for offline use

Discussion: What’s the Most Useful find Trick You Use?

Drop a comment below and share your best find command use case!

...

🔧 Master the Find Command: Stop Searching Manually in Linux


📈 59.04 Punkte
🔧 Programmierung

🔧 Grok 3: AI Thông Minh Nhất Thế Giới


📈 28.58 Punkte
🔧 Programmierung

🕵️ Kèo Thẻ Phạt Vip66 Là Gì? 3 Lối Đánh Kèo Chậm Mà Chắc


📈 28.58 Punkte
🕵️ Reverse Engineering

🔧 KISS Principle: Giữ Mọi Thứ Đơn Giản Nhất Có Thể


📈 28.58 Punkte
🔧 Programmierung

🔧 Có thể bạn chưa biết (Phần 1)


📈 28.58 Punkte
🔧 Programmierung

🔧 Tìm Hiểu Về RAG: Công Nghệ Đột Phá Đang "Làm Mưa Làm Gió" Trong Thế Giới Chatbot


📈 28.58 Punkte
🔧 Programmierung

📰 Stop Manually Sorting Your List In Python If Performance Is Concerned


📈 23.81 Punkte
🔧 AI Nachrichten

🔧 Stop Manually Coding UI Components! 🔼❌


📈 23.81 Punkte
🔧 Programmierung

🔧 Stop creating HTTP clients manually - Part I


📈 23.81 Punkte
🔧 Programmierung

🪟 How to start and stop services manually on Windows 10


📈 23.81 Punkte
🪟 Windows Tipps

📰 How To Manually Partition A Hard Drive From The Command Line On Linux


📈 22.84 Punkte
🖥️ Betriebssysteme

🐧 How To Manually Partition A Hard Drive From The Command Line On Linux


📈 22.84 Punkte
🐧 Linux Tipps

🐧 How To Manually Partition A Hard Drive From The Command Line On Linux


📈 22.84 Punkte
🐧 Linux Tipps

📰 How To Manually Partition A Hard Drive From The Command Line On Linux


📈 22.84 Punkte
🖥️ Betriebssysteme

🕵️ Find Hidden Info using Google Dorking manually, and Automated using Pagodo


📈 22.76 Punkte
🕵️ Hacking

🔧 Here Are All Popular PDF to Word Converters and Its Pros Cons - Stop Searching


📈 21.72 Punkte
🔧 Programmierung

📰 When Should You Stop Searching?


📈 21.72 Punkte
🔧 AI Nachrichten

📰 Attackers are searching for online store backups in public folders. Can they find yours?


📈 20.67 Punkte
📰 IT Security Nachrichten

🍏 Find the iPad case you’ve been searching for with Zugu


📈 20.67 Punkte
🍏 iOS / Mac OS

🔧 Tired of repeatedly searching the installation command so i made a CLI for it.


📈 18.78 Punkte
🔧 Programmierung

🐧 Searching and playing youtube videos simply with one command using fzf or dmenu.


📈 18.78 Punkte
🐧 Linux Tipps

📰 Getsploit v0.2.2 - Command Line Utility For Searching And Downloading Exploits


📈 18.78 Punkte
📰 IT Security Nachrichten

matomo