Linux find Cheatsheet

This cheatsheet provides a comprehensive and practical reference for the Linux find command. It covers searching by name, type, size, time, permissions, actions, advanced usage, and command combos. Use it to boost your productivity in file management and automation.

Basic Usage

find .
List all files and directories recursively from current directory
find /path -name 'file.txt'
Find file by name in a specific path
find /path -iname 'file.txt'
Case-insensitive name search
find /path -type f
Find all files
find /path -type d
Find all directories
find /path -maxdepth 1
Limit search depth to 1
find /path -mindepth 2
Start searching from depth 2

By Name & Pattern

find . -name '*.log'
Find all .log files
find . -iname '*.jpg'
Find all .jpg files (case-insensitive)
find . -not -name '*.txt'
Find files not ending with .txt
find . -regex '.*\.sh'
Find files matching regex pattern

By Size, Time & Permissions

find . -size +100M
Find files larger than 100MB
find . -size -10k
Find files smaller than 10KB
find . -empty
Find empty files and directories
find . -mtime -1
Find files modified in the last 1 day
find . -atime +7
Find files accessed more than 7 days ago
find . -perm 644
Find files with permission 644
find . -user username
Find files owned by a specific user
find . -group groupname
Find files owned by a specific group

Actions

find . -type f -delete
Delete all files found
find . -type f -exec rm {} +
Delete files using exec
find . -type f -exec chmod 644 {} +
Change permissions for found files
find . -type f -exec grep 'pattern' {} +
Search for pattern in found files
find . -type f -print0 | xargs -0 grep 'pattern'
Search pattern in files using xargs (handles spaces)
find . -type f -exec cp {} /tmp/ ;
Copy found files to /tmp/

Advanced & Special

find . -links +1
Find files with more than one hard link
find . -newer file.txt
Find files modified more recently than file.txt
find . -samefile file.txt
Find hard links to file.txt
find . -execdir ls -l {} +
Run command in the directory where the file is found
find . -type l
Find all symbolic links
find . -fstype ext4
Find files on ext4 filesystem

Command Combos

find . -type f -name '*.log' -delete
Find and delete all .log files recursively
find /var/log -type f -mtime +30 -exec rm {} +
Delete log files older than 30 days
find . -type f -exec du -h {} + | sort -hr | head -10
Show top 10 largest files found
find . -type f -print0 | xargs -0 grep 'TODO'
Find all files containing 'TODO'
find . -type f -exec md5sum {} + > files.md5
Generate MD5 checksums for all files

Categories

  • Basic Usage

    List files and directories, limit depth, and basic search patterns.

  • By Name & Pattern

    Search by file name, extension, case, and regex patterns.

  • By Size, Time & Permissions

    Search by file size, modification/access time, permissions, user, and group.

  • Actions

    Delete, copy, change permissions, and search content in found files.

  • Advanced & Special

    Advanced options, hard links, symlinks, filesystem, and execdir.

  • Command Combos

    Powerful multi-step workflows and advanced usage patterns for real-world scenarios.

Features

  • Quick search functionality
  • Organized by categories
  • Clear command descriptions
  • Common and advanced use cases covered
  • Easy to copy commands
  • Responsive design
  • Perfect for quick reference