Finding Things

As your file system grows, it becomes harder to remember exactly where you saved something. Linux provides two main tools for finding files: locate and find.

1. locate (Quick but indexed)

The locate command is incredibly fast because it searches a database of your file system rather than the files themselves.

Bash

locate index.html

Note: The locate database is usually updated once a day. If you just created a file a minute ago, locate might not find it yet!

2. find (Slow but accurate)

The find command is far more powerful and versatile. It searches the actual file system in real-time.

Bash

# Search by name in the current directory (.)
find . -name "notes.txt"

# Search for directories only
find . -type d

# Search for files only
find . -type f

# Search for files larger than 10MB
find . -size +10M

Which one should I use?