In this guide, you’ll learn how to quickly locate files on a Linux system using the powerfulDocumentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
find command. Whether you need to hunt down large log files, uncover recently modified documents, or filter by permissions, find provides flexible options to suit your needs.
By default, files on Linux are organized under standard directories:
- SSH daemon configurations:
/etc/ssh - System logs:
/var/log
- Locate all image files beneath your web directory
- Identify huge files when disk space is low
- List files modified or created within a specific timeframe
Basic Usage
The general syntax is:search_path, find searches the current directory.
Omitting the search path is equivalent to specifying
. (the current directory).Examples
Specifying the Search Path First
Always place the directory to search before your search criteria. Incorrect (no results under/bin):
Name-Based Searches
-name: case-sensitive filename match-iname: case-insensitive filename match- Wildcards (
*) match any sequence of characters
Time-Based Searches
You can filter files based on modification or change times.Modified Time by Minutes (-mmin)
| Syntax | Description |
|---|---|
n | exactly n minutes ago |
-n | within the last n minutes |
+n | more than n minutes ago |
Modified Time by Days (-mtime)
0: within the last 24 hours1: between 24 and 48 hours ago+n: more than n days ago-n: less than n days ago
Change Time (-ctime)
Tracks metadata changes (permissions, ownership):
Size-Based Searches
Filter files by size using the following suffixes:| Suffix | Unit |
|---|---|
c | bytes |
k | kilobytes |
M | megabytes |
G | gigabytes |
| Syntax | Description |
|---|---|
n | exactly n units |
-n | less than n units |
+n | more than n units |
Combining Expressions
By default, multiple expressions are combined with AND:OR Operator
Use-o to OR expressions:
NOT Operator
Negate conditions with-not or an escaped !:
Permission-Based Searches
Search by file permission bits (octal notation):| Mode Format | Description |
|---|---|
mode | exact match |
-mode | at least the bits in mode |
/mode | any of the bits in mode |
664 = rw-rw-r--):
Be careful to quote wildcard patterns (e.g.,
"*.txt"), especially when running in scripts or complex shells.