KIM COMPUTER


find (Search for Files)

The find command is a built-in Linux tool for searching and locating a list of files and directories based on conditions you specify. It is incredibly versatile, allowing you to filter by name, size, modification date, permissions, and more.


1. Basic Usage

find [path] [expression] [action]

2. Key Search Criteria

Criterion Description
-name Search by filename (case-sensitive).
-iname Search by filename (case-insensitive).
-type Search by type (f for file, d for directory).
-size Search by size (e.g., +50M for larger than 50MB).
-mtime Search by modification time (e.g., -1 for last 24 hours).
-user Search for files owned by a specific user.

3. Practical Examples

① Finding a file by name

find /home -name "profile.png"

② Finding all directories named 'src'

find . -type d -name "src"

③ Finding files modified in the last 7 days

find . -type f -mtime -7

④ Executing a command on found files

To change permissions for all .sh files found:

find . -name "*.sh" -exec chmod +x {} \;

4. [Tip] Efficiency

When searching system-wide, it is better to specify a starting directory (like /etc or /var) rather than searching from the root (/) to save time and system resources.