Anda di halaman 1dari 20

7/1/2018 35 Practical Examples of Linux Find Command

Linux Foundation’s LFCS and LFCE Certi cation Preparation Guide ($39) Get This Book   

Multifunction ADC, DAC, DIO, timers,


counters and excellent
DAQ Devices support for $115.

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 1/20
7/1/2018 35 Practical Examples of Linux Find Command

CENTOS / FEDORA / LINUX COMMANDS / LINUX DISTROS / REDHAT  126 I  TecMint :     

 BEGINNER'S GUIDE FOR LINUX 


35 Practical Examples of Linux Find Start learning Linux in minutes 

Command
by Ravi Saive | Published: July 18, 2012 | Last Updated: November 30, 2016

SPONSORED SEARCHES

Linux Shell Scripting

Name Search

 Download Your Free eBooks NOW - 10 Free Linux eBooks for Administrators | 4 Free
Shell Scripting eBooks

The Linux Find Command is one of the most important and


 Vi/Vim Editor BEGINNER'S GUIDE 
much used command in Linux sytems. Find command used to Learn vi/vim as a Full Text Editor 
search and locate list of les and directories based on
conditions you specify for les that match the arguments. Find
can be used in variety of conditions like you can nd les by
permissions, users, groups, le type, date, size and other
possible criteria.

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 2/20
7/1/2018 35 Practical Examples of Linux Find Command

35 Linux Find Commands Examples


 Linux Foundation Certi cation 
Exam Study Guide to LFCS and LFCE
Through this article we are sharing our day-to-day Linux nd
command experience and its usage in the form of examples. In
this article we will show you the most used 35 Find Commands
examples in Linux. We have divided the section into Five parts
from basic to advance usage of nd command.

Part I: Basic Find Commands for Finding Files with Names


Part II: Find Files Based on their Permissions
Part III: Search Files Based On Owners and Groups
Part IV: Find Files and Directories Based on Date and Time
Part V: Find Files and Directories Based on Size
Part VI: Find Multiple Filenames in Linux
 

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 3/20
7/1/2018 35 Practical Examples of Linux Find Command

How to Add Linux Host to Nagios Monitoring


Part I – Basic Find Commands for Finding Files with Server Using NRPE Plugin

Names
How to Install Nagios 4.3.4 on RHEL, CentOS and
Fedora
1. Find Files Using Name in Current
Install Cacti (Network Monitoring) on
Directory RHEL/CentOS 7.x/6.x/5.x and Fedora 24-12

Find all the les whose name is tecmint.txt in a current Google Chrome 65 Released – Install on
working directory. RHEL/CentOS 7 and Fedora 27-20

How to Install Ubuntu 16.10/16.04 Alongside With


# find . -name tecmint.txt Windows 10 or 8 in Dual-Boot
./tecmint.txt

2. Find Files Under Home Directory


Find all the les under /home directory with name tecmint.txt.

# find /home -name tecmint.txt


/home/tecmint.txt

3. Find Files Using Name and Ignoring Case

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 4/20
7/1/2018 35 Practical Examples of Linux Find Command

Find all the les whose name is tecmint.txt and contains both
capital and small letters in /home directory.

# find /home -iname tecmint.txt


./tecmint.txt
./Tecmint.txt

4. Find Directories Using Name


Find all directories whose name is Tecmint in / directory.

# find / -type d -name Tecmint


/Tecmint

5. Find PHP Files Using Name


Find all php les whose name is tecmint.php in a current
working directory. Linux System Administrator Bundle
with 7-Courses (96% off)
# find . -type f -name tecmint.php
./tecmint.php
Add to Cart - $69
 Ending In: 3 days
6. Find all PHP Files in Directory
Computer Hacker Professional
Find all php les in a directory. Certi cation Course (96% Off)

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 5/20
7/1/2018 35 Practical Examples of Linux Find Command

# find . -type f -name "*.php"


./tecmint.php
Add to Cart - $59
./login.php
 Ending In: 4 days
./index.php

LINUX EBOOKS
Part II – Find Files Based on their Permissions
Introducing Learn Linux In One Week and Go
from Zero to Hero
7. Find Files With 777 Permissions RedHat RHCE/RHCSA Certi cation Preparation
Guide
Find all the les whose permissions are 777.
Linux Foundations LFCS/LFCE Certi cation
Guide
# find . -type f -perm 0777 -print Post x Mail Server Setup Guide for Linux
Ansible Setup Guide for Linux
Django Setup Guide for Linux
8. Find Files Without 777 Permissions
Awk Getting Started Guide for Beginners
Find all the les without permission 777. Citrix XenServer Setup Guide for Linux

# find / -type f ! -perm 777


    

Never Miss Any Linux Tutorials,


9. Find SGID Files with 644 Permissions Guides, Tips and Free eBooks
Find all the SGID bit les whose permissions set to 644. Join Our Community Of 150,000+ Linux Lovers
and get a weekly newsletter in your inbox

# find / -perm 2644


YES! SIGN ME UP

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 6/20
7/1/2018 35 Practical Examples of Linux Find Command

10. Find Sticky Bit Files with 551


Permissions
Find all the Sticky Bit set les whose permission are 551.

# find / -perm 1551

11. Find SUID Files


Find all SUID set les.

# find / -perm /u=s

12. Find SGID Files


Find all SGID set les.

# find / -perm /g=s

13. Find Read Only Files


Find all Read Only les.

# find / -perm /u=r

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 7/20
7/1/2018 35 Practical Examples of Linux Find Command

14. Find Executable Files


Find all Executable les.

# find / -perm /a=x

15. Find Files with 777 Permissions and


Chmod to 644
Find all 777 permission les and use chmod command to set
permissions to 644.

# find / -type f -perm 0777 -print -exec chmod 644 {}

16. Find Directories with 777 Permissions


and Chmod to 755
Find all 777 permission directories and use chmod command
to set permissions to 755.

# find / -type d -perm 777 -print -exec chmod 755 {} \

17. Find and remove single File


https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 8/20
7/1/2018 35 Practical Examples of Linux Find Command

To nd a single le called tecmint.txt and remove it.

# find . -type f -name "tecmint.txt" -exec rm -f {} \;

18. Find and remove Multiple File


To nd and remove multiple les such as .mp3 or .txt, then
use.

# find . -type f -name "*.txt" -exec rm -f {} \;


OR
# find . -type f -name "*.mp3" -exec rm -f {} \;

19. Find all Empty Files


To nd all empty les under certain path.

# find /tmp -type f -empty

20. Find all Empty Directories


To le all empty directories under certain path.

# find /tmp -type d -empty

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 9/20
7/1/2018 35 Practical Examples of Linux Find Command

21. File all Hidden Files


To nd all hidden les, use below command.

# find /tmp -type f -name ".*"

Part III – Search Files Based On Owners and Groups

22. Find Single File Based on User


To nd all or single le called tecmint.txt under / root directory
of owner root.

# find / -user root -name tecmint.txt

23. Find all Files Based on User


To nd all les that belongs to user Tecmint under /home
directory.

# find /home -user tecmint

24. Find all Files Based on Group

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 10/20
7/1/2018 35 Practical Examples of Linux Find Command

To nd all les that belongs to group Developer under /home SHARE


directory.
+

# find /home -group developer 


0

25. Find Particular Files of User 


To nd all .txt les of user Tecmint under /home directory. 0

# find /home -user tecmint -iname "*.txt" 


0

Part IV – Find Files and Directories Based on Date and 


Time

26. Find Last 50 Days Modi ed Files


To nd all the les which are modi ed 50 days back.

# find / -mtime 50

27. Find Last 50 Days Accessed Files


To nd all the les which are accessed 50 days back.

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 11/20
7/1/2018 35 Practical Examples of Linux Find Command

# find / -atime 50

28. Find Last 50-100 Days Modi ed Files


To nd all the les which are modi ed more than 50 days back
and less than 100 days.

# find / -mtime +50 –mtime -100

29. Find Changed Files in Last 1 Hour


To nd all the les which are changed in last 1 hour.

# find / -cmin -60

30. Find Modi ed Files in Last 1 Hour


To nd all the les which are modi ed in last 1 hour.

# find / -mmin -60

31. Find Accessed Files in Last 1 Hour


To nd all the les which are accessed in last 1 hour.

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 12/20
7/1/2018 35 Practical Examples of Linux Find Command

# find / -amin -60

Part V – Find Files and Directories Based on Size

32. Find 50MB Files


To nd all 50MB les, use.

# find / -size 50M

33. Find Size between 50MB – 100MB


To nd all the les which are greater than 50MB and less than
100MB.

# find / -size +50M -size -100M

34. Find and Delete 100MB Files


To nd all 100MB les and delete them using one single
command.

# find / -size +100M -exec rm -rf {} \;

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 13/20
7/1/2018 35 Practical Examples of Linux Find Command

35. Find Speci c Files and Delete


Find all .mp3 les with more than 10MB and delete them using
one single command.

# find / -type f -name *.mp3 -size +10M -exec rm {} \;

That’s it, We are ending this post here, In our next article we
will discuss more about other Linux commands in depth with
practical examples. Let us know your opinions on this article
using our comment section.

If You Appreciate What We Do Here On


TecMint, You Should Consider:
1. Stay Connected to: Twitter | Facebook | Google Plus
2. Subscribe to our email updates: Sign Up Now
3. Get your own self-hosted blog with a Free Domain at
($3.45/month).
4. Become a Supporter - Make a contribution via PayPal

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 14/20
7/1/2018 35 Practical Examples of Linux Find Command

5. Support us by purchasing our premium books in PDF


format.
6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Ravi Saive View all Posts


I am Ravi Saive, creator of TecMint. A Computer Geek and

Linux Guru who loves to share tricks and tips on Internet. Most Of My
Servers runs on Open Source Platform called Linux. Follow Me: Twitter,
Facebook and Google+

Your name can also be listed here. Got a tip? Submit it


here to become an TecMint author.

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 15/20
7/1/2018 35 Practical Examples of Linux Find Command

PREVIOUS STORY NEXT STORY

 Fedora 17 Step by Step Installation Install Firefox 14 in RHEL – CentOS 


Guide with Screenshots – Fedora

 YOU MAY ALSO LIKE...

 11 0 2

8 Linux Nslookup
Commands to
Troubleshoot DNS
Fedora 20 (Heisenbug) How to Identify Working
(Domain Name Server)
Released – Download Directories Using Shell
13 AUG, 2012 DVD ISO Images Characters and
18 DEC, 2013
Variables
13 AUG, 2016

126 RESPONSES

 Comments 11  Pingbacks 0

lingaswamy  June 27, 2018 at 8:38 am


excellent info

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 16/20
7/1/2018 35 Practical Examples of Linux Find Command

Reply

somesh  May 2, 2018 at 4:40 pm


Hello,
How to nd the les that are created in particular year??
Reply

vikas Mhamunkar  April 28, 2018 at 2:13 pm


extraordinary site for learning Linux….:)
Reply

S Govardhan Raju  May 11, 2017 at 4:06 pm


Sir,
Very much thankful for giving examples to nd command, but how to nd
particuler date les give me examples.
Govardhan Raju
Reply

Ravi Saive  May 12, 2017 at 10:52 am


 @Govardhan,
You mean nd modi ed les by date? if yes, here is the article, take a
quick look.
Find Recent or Today’s Modi ed Files in Linux
Reply

Satyendra kushwaha  May 10, 2017 at 11:16 pm


Nice bro, your articles are awesome for Linux users.
Reply

Lalit Dalmia  April 19, 2017 at 1:58 am


Best site I ever have seen for the commands. A great work by you sir. Thanks a
lot for making Linux commands so easier.
Reply

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 17/20
7/1/2018 35 Practical Examples of Linux Find Command

Razeen  March 31, 2017 at 12:24 am


Good extensive write up on Find Commands Ravi, keep up the good work !!!
Reply

Ravi Saive  March 31, 2017 at 11:11 am


 @Razeen,
Thanks for nding it useful and thanks for appreciating my work..
Reply

Luvpreet  March 10, 2017 at 2:18 pm


Tecmint is life for linux people.
Reply

Ravi Saive  March 10, 2017 at 2:56 pm


 @Luvpreet,
Thanks for such kind words…:)
Reply

« Older Comments

GOT SOMETHING TO SAY? JOIN THE DISCUSSION.

Comment

Name * Email *

Website
https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 18/20
7/1/2018 35 Practical Examples of Linux Find Command

Save my name, email, and website in this browser for the next time I comment.

Notify me of followup comments via e-mail. You can also subscribe without
commenting.

Post Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

LINUX MONITORING TOOLS LINUX INTERVIEW QUESTIONS OPEN SOURCE TOOLS

Installing “PHP Server Monitor” Tool 10 Useful Interview Questions and 8 Best Open Source Music Making
using LEMP or LAMP Stack in Arch Answers on Linux Commands Softwares for Linux
Linux

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 19/20
7/1/2018 35 Practical Examples of Linux Find Command

3 Ways to Check Apache Server Status 10 Useful ‘ls’ Command Interview 15 Best Linux Photo/Image Editors I
and Uptime in Linux Questions – Part 2 Discovered in 2015

4 Useful Commandline Tools to 10 Useful ‘Interview Questions and 4 Best Command-Line Email Clients
Monitor MySQL Performance in Linux Answers’ on Linux Shell Scripting For Linux

Arpwatch Tool to Monitor Ethernet 15 Basic MySQL Interview Questions My Favorite Command Line Editors for
Activity in Linux for Database Administrators Linux – What’s Your Editor?

How to Con gure Custom Access and 10 Useful Random Linux Interview 3 Useful GUI and Terminal Based Linux
Error Log Formats in Nginx Questions and Answers Disk Scanning Tools


Tecmint: Linux Howtos, Tutorials & Guides © 2018. All Rights Reserved.
The material in this site cannot be republished either online or o ine,     
without our permission.

https://www.tecmint.com/35-practical-examples-of-linux-find-command/ 20/20

Anda mungkin juga menyukai