How to locate files and folders on Linux systems

Last updated: 2025-10-20
keywords: linux, find, file search, find files, locate, modified time
Solution under review

Environment

  • Linux systems (Ubuntu, Rocky Linux, etc.)

Issue

  • Locate files or folders on Linux systems

  • Find accidentally moved files or directories

  • Need to find recently modified files (e.g., files modified today or yesterday)

Resolution

Finding recently modified files

Find files modified within a specific time period:

$ # Files modified in the last 24 hours (today)
$ find . -type f -mtime -1
./data/output.csv
./logs/application.log
./workspace/notes.txt

$ # Files modified in the last 7 days
$ find . -type f -mtime -7
./reports/weekly_summary.xlsx
./data/recent_analysis.csv

$ # Files modified more than 30 days ago
$ find . -type f -mtime +30
./archive/old_data.csv
./backup/legacy_files/document.txt

Note

  • -mtime -1 means modified less than 1 day ago (within last 24 hours)

  • -mtime +30 means modified more than 30 days ago

  • -mtime 7 means modified between 7 and 8 days ago

For more precise time control (minutes):

$ # Files modified in the last 60 minutes (1 hour)
$ find . -type f -mmin -60
./logs/application.log

$ # Files modified in the last 10 minutes
$ find . -type f -mmin -10
./workspace/current_work.txt

Combining search criteria

Combine name patterns with time filters:

$ # Find PDF files modified in the last day
$ find . -type f -name "*.pdf" -mtime -1
./reports/daily_report_2024-12-20.pdf

$ # Find Python files in scripts directory modified in last week
$ find ./scripts -type f -name "*.py" -mtime -7
./scripts/new_feature.py
./scripts/bugfix.py

$ # Find log files older than 7 days
$ find . -type f -name "*.log" -mtime +7
./logs/application.log.2024-12-01
./logs/access.log.old

Limit search depth:

$ # Search only in current directory (not subdirectories)
$ find . -maxdepth 1 -name "*report*"
./report.txt

$ # Search only 2 levels deep
$ find . -maxdepth 2 -type f -name "*.txt"
./notes.txt
./documents/readme.txt

Exclude specific directories:

$ # Exclude .git and node_modules directories. -prune is more efficient.
$ find . \( -path './.git' -o -path './node_modules' \) -prune -o -type f -name "*report*"
./src/report_generator.py
./docs/report_template.md

Practical examples for finding missing files

Common scenarios for locating files:

$ # Find all files modified today in home directory
$ find ~ -type f -mtime -1

$ # Find a file you worked on yesterday (more precise)
$ find ~ -type f -daystart -mtime 1 -name "*presentation*"

$ # Find all Excel files in home directory
$ find ~ -type f -name "*.xlsx" -o -name "*.xls"

$ # Find large files (bigger than 100MB) modified this week
$ find . -type f -size +100M -mtime -7

$ # Find files owned by specific user
$ find . -type f -user username

Root Cause

Files may appear missing on Linux systems due to:

  • Accidentally moved to different directory

  • Saved with slightly different name than expected

  • Located in unexpected subdirectory

  • Hidden files (starting with dot .)

The find command is a standard Unix tool that:

  • Comes pre-installed on all Linux systems

  • Recursively searches directory trees

  • Supports complex search criteria

  • Can perform actions on found files

While the syntax may seem complex initially, find is powerful and universally available, making it the most reliable tool for file search on Linux systems.

References

  • find manual: Use man find for complete documentation

  • Common find examples: find --help