SlideShare a Scribd company logo
1 of 5
Download to read offline
thegeekscope.com                        http://w w w .thegeekscope.com/find-files-in-linux-using-find-
                                           command/



Find Files in Linux using Find Command
In Linux, find Command is used to search for specific files and folders. The beauty of the linux find
command lies in its ability to perform complex searches. Find command provides plenty of options to
specify size, modification date, type, owner, permission while performing a search operation.

This article describes some of the most useful options availble with the linux find command with the
help of examples.


Find Files Based on Filename Pattern
Syntax:


 find <SEARCH_PATH> -type [f|d] -name "<PATTERN>"


type ‘f’ indicates that search for files
type ‘d’ indicates that search for directories
                                    The Geek Scope
Example: Search for files in the /root folder which contains the string “monitor” in the filename


 # find /root -type f -name "*monitor*"
 /root/monitor_script.sh
 /root/monitor_script.sh.v2
 /root/monitor_script.sh.v1


Example: Search for folders in the /root folder which contains the string “monitor” in the foldername


 # find /root -type d -name "*monitor*"
 /root/test/test_monitor123


Example: Search for files/folders in the /root folder which contains the string “monitor” in the name


 # find /root -name "*monitor*"
 /root/test/test_monitor123
 /root/monitor_script.sh
 /root/monitor_script.sh.v2
 /root/monitor_script.sh.v1


                                                                          www.thegeekscope.com
Find Files Based on Modification Time in Days
Syntax:


 find <SEARCH_PATH> -mtime <x>


          Integer <x> indicates days

          <x> along with ‘+’ sign indicates, modified before x days

          <x> along with ‘-’ sign indicates, modified within last x days

          <x> with no sign indicates, modified exactly x days ago

Example: Search /etc folder for files/folders modified exactly 7 days ago


 # find /etc -mtime 7


Example: Search /etc folder for files/folders modified before 7 days


 # find /etc -mtime +7
                                       The Geek Scope
Example: Search /etc folder for files/folders modified in last 7 days


 # find /etc -mtime -7


You can use ‘atime‘ in place of ‘mtime’ to find files and folders based on last access time in days.

Example: Search /etc folder for files/folders accessed in last 7 days


 # find /etc -atime -7


Find Files Based on Modification Time in Mins
Syntax:


 find <SEARCH_PATH> -mmin <x>


          Integer <x> indicates minutes

                                                                           www.thegeekscope.com
<x> along with ‘+’ sign indicates, modified before x mins

          <x> along with ‘-’ sign indicates, modified within last x mins

          <x> with no sign indicates, modified exactly x mins ago

Example: Search /home folder for files/folders modified exactly 60 minutes ago


 # find /home -mmin 60


Example: Search /home folder for files/folders modified before 60 minutes


 # find /home -mmin +60


Example: Search /home folder for files/folders modified in last 60 minutes


 # find /home -mmin -60


You can use ‘amin‘ in place of ‘mmin’ to find files and folders based on last access time in mins.

                                     The Geek Scope
Example: Search /etc folder for files/folders accessed in last 60 mins


 # find /etc -amin -60


Find Files Based on Size
Syntax:


 find <SEARCH_PATH> -size <x>


Integer <x> indicates size in bytes/kilobytes/megabytes/gigabytes

          <x> along with ‘+’ sign indicates size larger than x

          <x> along with ‘-’ sign indicates size smaller than x

          <x> with no sign indicates, size exactly equal to x

Example: Search /etc folder for files/folders having size exactly equal to 20015 bytes



                                                                           www.thegeekscope.com
# find /etc -size 20015c


Example: Search /root folder for files/folders having size greater than 2 megabytes


 # find /etc -size +2M


Example: Search /home folder for files/folders having size less than 1 kilobytes


 # find /etc -size -1k


Find Files Based on Permissions
Syntax:


 find <SEARCH_PATH> -perm <permission>


Example: Search /etc folder for files/folders with permission 755 (read,write,execute for owner and
read,execute for group owner and others)
                                   The Geek Scope
 # find /etc -type f -perm 664



Find Empty files and Folders
Syntax:


 find -empty


Example: Find all empty files/folders available in a system


 # find / -empty



Find Files Owned by a Specific User
Syntax:


 find <SEARCH_PATH> -user <username>
                                                                      www.thegeekscope.com
Example: Find all files/folders owned by user ‘kam’


 # find / -user kam



Find Files Owned by a Specific Group
Syntax:


 find <SEARCH_PATH> -group <groupname>


Example: Find all files/folders owned by group account ‘projectx’


 # find / -group projectx


Use ‘-and’ and ‘-or’ qualifier to join search patterns
Example: Search /root folder for files/folders modified in last 7 days and having size less than 200kB

                                   The Geek Scope
 # find /etc -mtime -7 -and -size -200k


Example: Search /home folder for files/folders accessed in last 2 hours or having size greater than
10MB


 # find /etc -amin -120 -or -size +10M


Tagged as: Find Command, Find Files, Find files in LInux, Find files in Unix, Linux Find Command,
Search Files, Using Find Command




                                                                      www.thegeekscope.com

More Related Content

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Featured

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Saba Software
 

Featured (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Thegeekscope.com find files-in_linux_using_find_command

  • 1. thegeekscope.com http://w w w .thegeekscope.com/find-files-in-linux-using-find- command/ Find Files in Linux using Find Command In Linux, find Command is used to search for specific files and folders. The beauty of the linux find command lies in its ability to perform complex searches. Find command provides plenty of options to specify size, modification date, type, owner, permission while performing a search operation. This article describes some of the most useful options availble with the linux find command with the help of examples. Find Files Based on Filename Pattern Syntax: find <SEARCH_PATH> -type [f|d] -name "<PATTERN>" type ‘f’ indicates that search for files type ‘d’ indicates that search for directories The Geek Scope Example: Search for files in the /root folder which contains the string “monitor” in the filename # find /root -type f -name "*monitor*" /root/monitor_script.sh /root/monitor_script.sh.v2 /root/monitor_script.sh.v1 Example: Search for folders in the /root folder which contains the string “monitor” in the foldername # find /root -type d -name "*monitor*" /root/test/test_monitor123 Example: Search for files/folders in the /root folder which contains the string “monitor” in the name # find /root -name "*monitor*" /root/test/test_monitor123 /root/monitor_script.sh /root/monitor_script.sh.v2 /root/monitor_script.sh.v1 www.thegeekscope.com
  • 2. Find Files Based on Modification Time in Days Syntax: find <SEARCH_PATH> -mtime <x> Integer <x> indicates days <x> along with ‘+’ sign indicates, modified before x days <x> along with ‘-’ sign indicates, modified within last x days <x> with no sign indicates, modified exactly x days ago Example: Search /etc folder for files/folders modified exactly 7 days ago # find /etc -mtime 7 Example: Search /etc folder for files/folders modified before 7 days # find /etc -mtime +7 The Geek Scope Example: Search /etc folder for files/folders modified in last 7 days # find /etc -mtime -7 You can use ‘atime‘ in place of ‘mtime’ to find files and folders based on last access time in days. Example: Search /etc folder for files/folders accessed in last 7 days # find /etc -atime -7 Find Files Based on Modification Time in Mins Syntax: find <SEARCH_PATH> -mmin <x> Integer <x> indicates minutes www.thegeekscope.com
  • 3. <x> along with ‘+’ sign indicates, modified before x mins <x> along with ‘-’ sign indicates, modified within last x mins <x> with no sign indicates, modified exactly x mins ago Example: Search /home folder for files/folders modified exactly 60 minutes ago # find /home -mmin 60 Example: Search /home folder for files/folders modified before 60 minutes # find /home -mmin +60 Example: Search /home folder for files/folders modified in last 60 minutes # find /home -mmin -60 You can use ‘amin‘ in place of ‘mmin’ to find files and folders based on last access time in mins. The Geek Scope Example: Search /etc folder for files/folders accessed in last 60 mins # find /etc -amin -60 Find Files Based on Size Syntax: find <SEARCH_PATH> -size <x> Integer <x> indicates size in bytes/kilobytes/megabytes/gigabytes <x> along with ‘+’ sign indicates size larger than x <x> along with ‘-’ sign indicates size smaller than x <x> with no sign indicates, size exactly equal to x Example: Search /etc folder for files/folders having size exactly equal to 20015 bytes www.thegeekscope.com
  • 4. # find /etc -size 20015c Example: Search /root folder for files/folders having size greater than 2 megabytes # find /etc -size +2M Example: Search /home folder for files/folders having size less than 1 kilobytes # find /etc -size -1k Find Files Based on Permissions Syntax: find <SEARCH_PATH> -perm <permission> Example: Search /etc folder for files/folders with permission 755 (read,write,execute for owner and read,execute for group owner and others) The Geek Scope # find /etc -type f -perm 664 Find Empty files and Folders Syntax: find -empty Example: Find all empty files/folders available in a system # find / -empty Find Files Owned by a Specific User Syntax: find <SEARCH_PATH> -user <username> www.thegeekscope.com
  • 5. Example: Find all files/folders owned by user ‘kam’ # find / -user kam Find Files Owned by a Specific Group Syntax: find <SEARCH_PATH> -group <groupname> Example: Find all files/folders owned by group account ‘projectx’ # find / -group projectx Use ‘-and’ and ‘-or’ qualifier to join search patterns Example: Search /root folder for files/folders modified in last 7 days and having size less than 200kB The Geek Scope # find /etc -mtime -7 -and -size -200k Example: Search /home folder for files/folders accessed in last 2 hours or having size greater than 10MB # find /etc -amin -120 -or -size +10M Tagged as: Find Command, Find Files, Find files in LInux, Find files in Unix, Linux Find Command, Search Files, Using Find Command www.thegeekscope.com