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.

Linux Find Cheatsheet

Master the find command for file searching

52

Commands

8

Categories

0

Favorites

13

Sections

Basic
Basic Usage
find .

List all files recursively

find /path

Search in specific path

find . -maxdepth 1

Current directory only

find . -maxdepth 2

Limit depth to 2 levels

find . -mindepth 2

Start from depth 2

Basic
Output Control
find . -print

Print full path (default)

find . -print0

Null delimiter (for xargs -0)

find . -printf '%f\n'

Print filename only

find . -ls

List in ls -l format

Name
By Name
find . -name 'file.txt'

Exact name (case-sensitive)

find . -iname 'file.txt'

Name (case-insensitive)

find . -name '*.log'

Find all .log files

find . -name '*.jpg' -o -name '*.png'

Find .jpg OR .png

find . -not -name '*.txt'

NOT ending with .txt

Name
By Path
find . -path '**/test/*'

Match full path pattern

find . -ipath '**/test/*'

Path (case-insensitive)

Type
By File Type
find . -type f

Regular files only

find . -type d

Directories only

find . -type l

Symbolic links

find . -empty

Empty files and directories

find . -type f -empty

Empty files only

find . -type d -empty

Empty directories only

Size
By File Size
find . -size +100M

Larger than 100MB

find . -size -10k

Smaller than 10KB

find . -size 50M

Exactly 50MB

find . -size +1G

Larger than 1GB

find . -size +100M -size -500M

Between 100MB and 500MB

💡 Size units: c (bytes), k (KB), M (MB), G (GB)

Time
By Modification Time
find . -mtime -1

Modified in last 24 hours

find . -mtime +7

Modified more than 7 days ago

find . -mmin -60

Modified in last 60 minutes

find . -newer file.txt

Newer than file.txt

Time
By Access Time
find . -atime -1

Accessed in last 24 hours

find . -amin -30

Accessed in last 30 minutes

find . -newermt '2024-01-01'

Modified after date

💡 -mtime: modification, -atime: access, -ctime: status change

Permissions
By Permissions
find . -perm 644

Exact permission 644

find . -perm -644

At least 644 permissions

find . -perm -u+x

User executable files

Permissions
By Owner
find . -user username

Files owned by user

find . -group groupname

Files owned by group

find . -nouser

Files with no valid owner

Actions
Execute Commands
find . -exec cmd {} \;

Execute for each file

find . -exec cmd {} +

Execute with all files at once

find . -ok cmd {} \;

Execute with confirmation

find . -print0 | xargs -0 cmd

Use xargs (handles spaces)

💡 {} is replaced with filename, \; ends command

Actions
Common Actions
find . -type f -delete

Delete found files

find . -exec chmod 644 {} +

Change permissions

find . -exec cp {} /dest/ \;

Copy files

Combos
Useful Combinations
find . -name '*.log' -mtime +30 -delete

Delete old logs

find . -type f -name '*.txt' -exec grep -l 'pattern' {} +

Find files with pattern

find . -type d -empty -delete

Remove empty directories

find . -name 'node_modules' -type d -prune -exec rm -rf {} +

Remove node_modules

find /tmp -type f -atime +7 -delete

Clean old temp files

Quick Reference

Basic syntax

find [path] [options]

Size units

c, k, M, G

Time units

-mtime (days), -mmin (min)

Execute

-exec cmd \;

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