Docs / Linux Basics / How to Use the find Command on Linux

How to Use the find Command on Linux

By Admin · Mar 2, 2026 · Updated Apr 23, 2026 · 30 views · 3 min read

Introduction to find

The find command is one of the most powerful utilities on Linux. It searches directories recursively based on criteria such as name, type, size, modification time, and permissions. Whether you are managing a Breeze or a bare-metal server, mastering find will dramatically improve your ability to locate and manage files.

Basic Syntax

find [starting-directory] [options] [expression]

If no starting directory is provided, find defaults to the current directory.

Finding Files by Name

# Find files named exactly "config.php"
find /var/www -name "config.php"

# Case-insensitive search
find /var/www -iname "readme.md"

# Wildcard pattern — all .log files
find /var/log -name "*.log"

# Find files matching multiple names
find /etc -name "*.conf" -o -name "*.cfg"

Finding by Type

# Files only
find /home -type f -name "*.txt"

# Directories only
find /var -type d -name "cache"

# Symbolic links
find /usr -type l

Finding by Size

# Files larger than 100MB
find / -type f -size +100M

# Files smaller than 1KB
find /tmp -type f -size -1k

# Files exactly 4096 bytes
find /etc -type f -size 4096c

Finding by Time

# Modified in the last 24 hours
find /var/log -type f -mtime -1

# Accessed more than 30 days ago
find /tmp -type f -atime +30

# Changed in the last 60 minutes
find /etc -type f -mmin -60

Finding by Permissions and Ownership

# Files with permission 777 (security risk)
find /var/www -type f -perm 0777

# Files owned by www-data
find /var/www -user www-data

# Files not owned by the expected user
find /var/www -not -user www-data

Executing Actions on Results

# Delete all .tmp files
find /tmp -type f -name "*.tmp" -delete

# Change permissions on found files
find /var/www -type f -exec chmod 644 {} \;

# Faster alternative using xargs
find /var/www -type f -print0 | xargs -0 chmod 644

# Copy matched files to another directory
find /home/user -name "*.bak" -exec cp {} /backup/ \;

Combining Conditions

# AND — files larger than 10MB AND modified in last 7 days
find /var -type f -size +10M -mtime -7

# OR — .log or .tmp files
find /var -type f \( -name "*.log" -o -name "*.tmp" \)

# NOT — all files except .php
find /var/www -type f -not -name "*.php"

Practical Examples

  • Find world-writable files: find / -type f -perm -o+w 2>/dev/null
  • Find empty directories: find /var -type d -empty
  • Find broken symlinks: find / -xtype l 2>/dev/null
  • Find files modified by a recent deployment: find /var/www -newer /tmp/deploy-marker

Performance Tip

Use -maxdepth to limit search depth and speed up queries on large file systems:

find / -maxdepth 3 -name "*.conf"

Was this article helpful?