- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
25 Practical Examples of Linux Find Command
Introduction
Linux Find Command is a powerful utility that enables you to search for files and directories on your system. command searches for files and directories based on various criteria, including file name, type, size, date modified, and ownership, among others.
This article provides 25 practical examples of how to use Linux Find Command to search for files and directories based on specific criteria.
Find Files by Name
The simplest way to use Linux Find Command is to search for files by name. For example, to search for all files with name "example.txt," use following command −
$ find / -name example.txt
This command will search for file "example.txt" in root directory and all subdirectories.
Find Directories by Name
You can also use Linux Find Command to search for directories by name. For example, to search for all directories with name "example," use following command −
$ find / -type d -name example
Find Files by Type
The Linux Find Command also allows you to search for files based on their type. For example, to search for all PDF files on your system, use following command −
$ find / -type f -name "*.pdf"
Find Files by Size
You can also use Linux Find Command to search for files based on their size. For example, to search for all files larger than 10MB on your system, use following command −
$ find / -type f -size +10M
Find Files by Date Modified
The Linux Find Command also allows you to search for files based on their date modified. For example, to search for all files modified within last 24 hours, use following command −
$ find / -type f -mtime -1
Find Files by User
You can also use Linux Find Command to search for files based on their owner. For example, to search for all files owned by user "john," use following command −
$ find / -type f -user john
Find Files by Permissions
The Linux Find Command also allows you to search for files based on their permissions. For example, to search for all files with read and write permissions for owner, use following command −
$ find / -type f -perm 600
Find Empty Files and Directories
The Linux Find Command can also be used to find empty files and directories. For example, to find all empty directories in root directory and all subdirectories, use following command −
$ find / -type d -empty
This command will search for all empty directories in root directory and all subdirectories.
Find Recently Accessed Files
You can use Linux Find Command to find files that have been accessed recently. For example, to find all files that have been accessed in last 7 days, use following command −
$ find / -type f -atime -7
Find Recently Modified Files
You can also use Linux Find Command to find files that have been modified recently. For example, to find all files that have been modified in last 7 days, use following command −
$ find / -type f -mtime -7
Find Files by Extension
You can use Linux Find Command to find files based on their extension. For example, to find all files with extension ".txt" in root directory and all subdirectories, use following command −
$ find / -type f -name "*.txt"
Find Files by Age
You can also use Linux Find Command to find files based on their age. For example, to find all files that are older than 30 days in root directory and all subdirectories, use following command −
$ find / -type f -mtime +30
Find Large Files
You can use Linux Find Command to find large files on your system. For example, to find all files larger than 100MB in root directory and all subdirectories, use following command −
$ find / -type f -size +100M
Find Files by Name and Ignore Case
You can use Linux Find Command to search for files by name and ignore case. For example, to search for all files with name "example.txt" and ignore case in root directory and all subdirectories, use following command −
$ find / -iname example.txt
Find Files by Modification Time
The Linux Find Command allows you to search for files based on their modification time. For example, to search for all files modified in last 10 minutes in root directory and all subdirectories, use following command −
$ find / -type f -mmin -10
Find Files by Access Time
You can also use Linux Find Command to find files based on their access time. For example, to find all files that have been accessed in last 24 hours in root directory and all subdirectories, use following command −
$ find / -type f -amin -1440
Find Files by User
You can use Linux Find Command to find files owned by a specific user. For example, to find all files owned by user "john" in root directory and all subdirectories, use following command −
$ find / -type f -user john
Find Directories by User
You can also use Linux Find Command to find directories owned by a specific user. For example, to find all directories owned by user "john" in root directory and all subdirectories, use following command −
$ find / -type d -user john
Find Files by Group
You can use Linux Find Command to find files owned by a specific group. For example, to find all files owned by group "users" in root directory and all subdirectories, use following command −
$ find / -type f -group users
Find Directories by Group
You can also use Linux Find Command to find directories owned by a specific group. For example, to find all directories owned by group "users" in root directory and all subdirectories, use following command −
$ find / -type d -group users
Find Files by Permissions
You can use Linux Find Command to find files based on their permissions. For example, to find all files with read and write permissions for owner in root directory and all subdirectories, use following command −
$ find / -type f -perm 600
Find Directories by Permissions
You can also use Linux Find Command to find directories based on their permissions. For example, to find all directories with read, write, and execute permissions for owner in root directory and all subdirectories, use following command −
$ find / -type d -perm 700
Find Files by Type
You can use Linux Find Command to find files based on their type. For example, to find all symbolic links in root directory and all subdirectories, use following command −
$ find / -type l ``
Find Files by Size
You can use Linux Find Command to find files based on their size. For example, to find all files larger than 1 megabyte in root directory and all subdirectories, use following command −
$ find / -type f -size +1M
Find Files with Multiple Criteria
You can use Linux Find Command to find files with multiple criteria. For example, to find all files modified in last 24 hours, owned by user "john," and larger than 1 megabyte in root directory and all subdirectories, use following command −
$ find / -type f -user john -size +1M -mtime -1
Conclusion
The Linux Find Command is a powerful tool that can be used to search for files and directories based on a variety of criteria. With examples provided in this article, you should have a good understanding of how to use this command to streamline your workflow and make managing your files and directories much easier. Whether you are a beginner or an experienced Linux user, Find Command is an essential tool that you should add to your arsenal.