• Skip to main content
  • Skip to primary sidebar
  • Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / Linux sysadmin tutorials linux system administrator / find Command in Linux with Examples

find Command in Linux with Examples

The find command is a powerful tool in Linux used for searching files and directories based on various conditions such as name, size, type, date, and permissions.


Table of Contents

Toggle
  • 1. Basic Syntax
  • 2. Find Files by Name
    • Case-Insensitive Search
  • 3. Find Files by Type
  • 4. Find Files by Size
  • 5. Find Files by Modification Time
  • 6. Find Files by Permissions
  • 7. Find and Delete Files
  • 8. Find and Execute Commands (-exec)
  • 9. Find and Print File Details
  • 10. Exclude a Directory from Search
  • 11. Find Empty Files and Directories
  • 12. Find Recently Accessed Files

1. Basic Syntax

find [path] [options] [expression]
  • [path] → The directory to search (default is current directory .).
  • [options] → Conditions like file name, type, size, etc.
  • [expression] → Actions to perform on found files.

2. Find Files by Name

find /home -name "file.txt"
  • Searches for file.txt in the /home directory.
  • -name is case-sensitive.

Case-Insensitive Search

find /home -iname "file.txt"
  • -iname ignores case differences.

3. Find Files by Type

find /home -type f
  • -type f → Finds only files.
find /home -type d
  • -type d → Finds only directories.
find /home -type l
  • -type l → Finds symbolic links.

4. Find Files by Size

find / -size +100M
  • Finds files larger than 100MB.
find / -size -50k
  • Finds files smaller than 50KB.
find / -size 1G
  • Finds files exactly 1GB in size.

5. Find Files by Modification Time

find /home -mtime -7
  • -mtime -7 → Files modified in the last 7 days.
find /home -mtime +30
  • -mtime +30 → Files modified more than 30 days ago.
find /home -mmin -60
  • -mmin -60 → Files modified in the last 60 minutes.

6. Find Files by Permissions

find / -perm 777
  • Finds files with 777 (full) permissions.
find / -perm -u=r
  • Finds files where the owner has read permission.
find / -perm -g=w
  • Finds files where the group has write permission.
find / -perm -o=x
  • Finds files where others have execute permission.

7. Find and Delete Files

find /tmp -name "*.log" -delete
  • Deletes all .log files in /tmp.
find /var/log -name "*.log" -mtime +30 -exec rm {} \;
  • Deletes .log files older than 30 days.

🚨 Be careful while using -delete or rm!


8. Find and Execute Commands (-exec)

find /var/www -name "*.php" -exec chmod 644 {} \;
  • Finds all .php files and changes permissions to 644.
find /home -type f -name "*.txt" -exec mv {} /backup/ \;
  • Moves all .txt files to /backup/.
find . -type f -exec grep "error" {} \;
  • Searches for the word “error” in all files.

9. Find and Print File Details

find /var/log -type f -exec ls -lh {} \;
  • Lists detailed information about each found file.

10. Exclude a Directory from Search

find / -path "/proc" -prune -o -name "*.log"
  • Skips /proc directory and searches for .log files.

11. Find Empty Files and Directories

find /tmp -type f -empty
  • Finds empty files.
find /tmp -type d -empty
  • Finds empty directories.

12. Find Recently Accessed Files

find /home -atime -1
  • Files accessed in the last 1 day.
find /home -amin -30
  • Files accessed in the last 30 minutes.

Primary Sidebar

Linux sysadmin tutorials linux system administrator

  • top 10 apt & apt-get commands (most used) apt vs apt-get
  • If-Else Statements in Shell Scripting
  • linux commands pdf (files & Directories, zip & unzip process, search etc)
  • Find Files with Specific Text on Linux grep find command
  • linux performance tuning inode limit file descriptors tco, kernel etc
  • Variables and Data Types in Shell Scripting
  • Top 10 most used Cat commands with examples (create, view, append files)
  • Ip tables / ufw / firewall d commands for block port ip rate limiting
  • Top 10 zip / tar commands to compress & extract files in linux
  • TOP 10 mv & cp commands in linux to move & copy files in Linux
  • Top 10 GREP Commands in linux to search files directory words strings
  • lsof netstat commands to know listening ports in linux 3 ways
  • Upgrade Ubuntu from 18.04 (19.10) to 20.04 LTS command line or gui server | desktop
  • 3 Ways (SCP, rsync, Sftp) linux server migration between two remote server apache nginx
  • linux system specs commands (CPU, Memory, Disk )speed, type. manufacture
  • linux sysctl command tweaks & hardening
  • linux security limits.conf deciding user limits process limits for nginx server
  • ulimit linux unlimited command unlimto set & know user limits open files file descriptor max user process etc.
  • red hat linux certification cost jobs salary syllabus courses fees
  • ufw firewall commads allow port enable disable ubuntu 20.04
  • ddos attack prevention
  • change ssh port in linux - avoid sshd ddos attacks
  • ping command
  • memcached install ubuntu wordpress
  • check linux version (lsb_release -a) ubuntu debian 32 or 64 bit
  • rsync command linux with examples comparison to scp
  • how to uninstall package in linux ubuntu rpm, yum apt-get
  • increase open file limit linux File descriptor ft nginx , mysql, lemp
  • remove repository ubuntu
  • htop commad memory details virtual vs shard vs resident
  • chown command in Linux with Examples
  • Kill PHP process
  • VIrtual Memory vs RSS Memory vs Shared memory in Linux
  • oom killer fixing it by configuration linux ubuntu
  • Install Lemp nginx mysql php fpm Stack on Debian 11 with repository
  • connect two remote servers linux command line
  • auto start after oom killer Mysql & php fpm nginx etc ubuntu wth systemd or cron job
  • load average Linux 1, 5, 15 min 2,4,8 cores explained
  • Control Structures in Shell Scripting
  • Shell Scripting Roadmap for Beginners to Advanced
  • awk commands with practical examples
  • Shell Scripting Tutorial for Beginners 🚀
  • find Command in Linux with Examples
  • sed Command in Linux with Examples (Beginner to Advanced)
  • Linux Text processing commands in with Examples
  • linux disk management commands
  • fdisk command in linux with examples
  • how to add a new disk in linux
  • Linux mount Command with Examples
  • fstab options with examples
  • Top 50 Shell Scripting Interview Questions and Answers
  • Linux Networking Interview Questions and Answers
  • Linux Networking Commands Cheat Sheet with Examples pdf
  • Netstat & SS Commands cheat sheet with examples Interview Questions
  • Nmap Cheat Sheet – Network Scanning & Security
  • Bash Brackets ([], (), {}, $( ), $(( ))) – Types, Uses & Examples

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy