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

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
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 WorkerThousandEyes
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
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 Processorsdebabhi2
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 

Recently uploaded (20)

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 

Featured

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)contently
 
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 2024Albert Qian
 
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 InsightsKurio // The Social Media Age(ncy)
 
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 2024Search Engine Journal
 
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 summarySpeakerHub
 
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 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 Tessa Mero
 
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 IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
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 managementMindGenius
 
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...RachelPearson36
 
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...Applitools
 
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 WorkGetSmarter
 
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...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
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 wellSaba 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