35 Practical Examples of Linux Find Command

The Linux find command is one of the most important and frequently used command-line utilities in Unix-like operating systems. The find command is used to search for and locate a list of files and directories based on the conditions you specify, matching the arguments.

The find command provides a wide array of options, allowing users to leverage it in diverse conditions. It empowers individuals to search for files based on a multitude of criteria, including permissions, users, groups, file types, dates, sizes, and various other parameters.

In this article, we will present you with 35 of the most commonly used examples of Find Commands in Linux. We have divided this section into five parts, covering the usage of the find command from basic to advanced levels.

Part I – Basic Find Commands for Finding Files with Names

When it comes to finding files with specific names, the find command offers a range of options to streamline the process. Here are some basic find commands for locating files based on their names.

1. Find Files Using Name in Current Directory

Find all the files whose name is tecmint.txt in a current working directory.

# find . -name tecmint.txt

./tecmint.txt

2. Find Files Under Home Directory

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

# find /home -name tecmint.txt

/home/tecmint.txt

3. Find Files Using Name and Ignoring Case

Find all the files 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 files whose name is tecmint.php in a current working directory.

# find . -type f -name tecmint.php

./tecmint.php

6. Find all PHP Files in the Directory

Find all php files in a directory.

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

./tecmint.php
./login.php
./index.php

Part II – Find Files Based on their Permissions

Here are some examples of find commands for finding files based on their permissions.

7. Find Files With 777 Permissions

Find all the files whose permissions are 777.

# find . -type f -perm 0777 -print

8. Find Files Without 777 Permissions

Find all the files without permission 777.

# find / -type f ! -perm 777

9. Find SGID Files with 644 Permissions

Find all the SGID bit files whose permissions are set to 644.

# find / -perm 2644

10. Find Sticky Bit Files with 551 Permissions

Find all the Sticky Bit set files whose permission is 551.

# find / -perm 1551

11. Find SUID Files

Find all SUID set files.

# find / -perm /u=s

12. Find SGID Files

Find all SGID set files.

# find / -perm /g=s

13. Find Read-Only Files

Find all Read-Only files.

# find / -perm /u=r

14. Find Executable Files

Find all Executable files.

# find / -perm /a=x

15. Find Files with 777 Permissions and Chmod to 644

Find all 777 permission files and use the 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 the chmod command to set permissions to 755.

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

17. Find and Remove Single File

To find a single file called tecmint.txt and remove it.

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

18. Find and remove Multiple File

To find and remove multiple files such as .mp3 or .txt, then use.

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

OR

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

[ You might also like: 4 Useful Tools to Find and Delete Duplicate Files in Linux ]

19. Find all Empty Files

To find all empty files under a certain path.

# find /tmp -type f -empty

20. Find all Empty Directories

To file all empty directories under a certain path.

# find /tmp -type d -empty

21. File all Hidden Files

To find all hidden files, use the below command.

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

Part III – Search Files Based On Owners and Groups

Here are some examples of find commands for finding files based on owners and groups:

22. Find Single File Based on User

To find all or single files called tecmint.txt under / root directory of owner root.

# find / -user root -name tecmint.txt

23. Find all Files Based on User

To find all files that belong to user Tecmint under /home directory.

# find /home -user tecmint

24. Find all Files Based on Group

To find all files that belong to the group Developer under /home directory.

# find /home -group developer

25. Find Particular Files of User

To find all .txt files of user Tecmint under /home directory.

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

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

Here are some examples of find commands for locating files and directories based on date and time.

26. Find Last 50 Days Modified Files

To find all the files which are modified 50 days back.

# find / -mtime 50

27. Find Last 50 Days Accessed Files

To find all the files which are accessed 50 days back.

# find / -atime 50

28. Find Last 50-100 Days Modified Files

To find all the files which are modified more than 50 days back and less than 100 days.

# find / -mtime +50 –mtime -100

29. Find Changed Files in Last 1 Hour

To find all the files which are changed in the last 1 hour.

# find / -cmin -60

30. Find Modified Files in Last 1 Hour

To find all the files which are modified in the last 1 hour.

# find / -mmin -60

31. Find Accessed Files in Last 1 Hour

To find all the files which are accessed in the last 1 hour.

# find / -amin -60

Part V – Find Files and Directories Based on Size

Here are some examples of find commands for locating files and directories based on size.

32. Find 50MB Files

To find all 50MB files, use.

# find / -size 50M

33. Find Size between 50MB – 100MB

To find all the files which are greater than 50MB and less than 100MB.

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

34. Find and Delete 100MB Files

To find all 100MB files and delete them using one single command.

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

35. Find Specific Files and Delete

Find all .mp3 files 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 other Linux commands in-depth with practical examples. Let us know your opinions on this article using our comment section.

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

149 thoughts on “35 Practical Examples of Linux Find Command”

  1. Countless examples that are EXACTLY THE SAME so this list of 35 could be condensed to a few examples. Then it’s missing in my opinion crucial searching based on patterns.

    Most of the examples show super arbitrary parameters on which to search files and each command is repeated a few times with minor differences like -perm 1664, -perm 7777 – I GET IT that.

    I can search on different permissions. Very little general knowledge can be inferred from these examples.

    Reply
  2. Please stop confusing people find is not a Linux command else a GNU command, Linux is a Kernel, not the project that embraces find.

    Reply
  3. I want to find the default notification email address for my centreon NMS. I don’t know in which file it was configured.

    How can I find [email protected] to change the email id, because my email server blocks it?

    Reply
  4. Very useful page – find otherwise is a huge topic in itself: this page helps you to get on with find quickly. Just one request. Kindly also add examples illustrating the use of "-maxdepth" option to limit find to the desired number of directories.

    Reply
  5. Hello all,

    Thanks in advance.

    I’m trying to find all the files with specific text in the file and have a timestamp next to the file.

    Below doesn’t work, I can use the find command but it doesn’t give me the timestamp

    $ find /u01/ -type f -name "*.trc" -exec grep -il error in job" {}\; -ls | sort;
    

    Thanks
    Dave

    Reply
  6. 34. Find and Delete 100MB Files

    To find all 100MB files and delete them using one single command.

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

    Does this command find files that are greater than 100 MB?

    Reply
    • Yes, it finds all the files which are more than 100MB under the root, and it will delete that files.

      +100M — > Means More than 100M files
      -100M —-> Means Less than 100M files
      100M —> Exact 100M files

      Reply
  7. Find files older than a prescribed number (e.g. 8) of newest files:

    $ find . -maxdepth 1 -type f -printf '%T@ %p
    $ find . -maxdepth 1 -type f -printf '%T@ %p\0' | sort -rnz | sed -z "1,8d; s/^.* //"
    
    ' | sort -rnz | sed -z "1,8d; s/^.* //"
    Reply
  8. A little comment: Before you do something very worse with the find command, execute find without -exec, you see, if you do the find at the right directory or you check if find does the things expected.

    In this example with find / -type f -size +100M you first check, are these the files I want to delete?

    Then you can add the -exec rm and so on

    Reply
  9. You should really remove this command from your example, or at least place a warning:

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

    for sure someone unwarned might execute this and remove the directories on the root, since rm -rf don’t make distinction between files and directories.

    The correct usage would be:

    # find / -type f -size +100M -exec rm -f {} \ -> 
    

    since type -f select only the files, and removing the -r (recursive) from rm.

    Still would warn about using this command, you have to be sure about running unspecific rm, even more on your root directory.

    Reply
    • I’m not sure I follow. When you say default what context do you mean? The current environment umask setting affects what the ‘default‘ permissions are. Files certainly don’t have a maximum of 0666 since files can have 0777 permissions as well.

      Reply
  10. Sir,

    Very much thankful for giving examples to find command, but how to find particuler date files give me examples.

    Govardhan Raju

    Reply
  11. 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
    • @Bhavik,

      Thanks a lot for finding our articles useful, and also good to hear that our articles helping you to learn Linux in an easy way..

      Reply
  12. guys,

    I m not able to login in to any of the user and getting the authentication failure, please help me on this

    Error in the logs

    [root@india etc]# grep rama2 /var/log/secure
    Jan 21 04:34:07 india useradd[4117]: new group: name=rama2, GID=504
    Jan 21 04:34:07 india useradd[4117]: new user: name=rama2, UID=504, GID=504, 
    home=/home/rama2, shell=/bin/bash
    Jan 21 04:34:16 india passwd: pam_unix(passwd:chauthtok): password changed for rama2
    Jan 21 04:34:20 india su: pam_unix(su:session): session opened for user rama2 by root(uid=0)
    Jan 21 04:35:16 india su: pam_unix(su:session): session closed for user rama2
    Jan 21 04:36:35 india su: pam_unix(su:session): session opened for user rama2 by root(uid=0)
    Jan 21 04:36:42 india su: pam_unix(su:session): session closed for user rama2
    Jan 21 04:42:19 india unix_chkpwd[4195]: password check failed for user (rama2)
    Jan 21 04:42:19 india pam: gdm-password[3902]: pam_unix(gdm-password:auth): 
    authentication failure; logname= uid=0 euid=0 tty=:1 ruser= rhost=  user=rama2
    Jan 21 04:48:33 india unix_chkpwd[2792]: password check failed for user (rama2)
    Jan 21 04:48:33 india login: pam_unix(login:auth): authentication failure; 
    logname=LOGIN uid=0 euid=0 tty=tty2 ruser= rhost=  user=rama2
    Jan 21 04:48:35 india login: FAILED LOGIN 1 FROM (null) FOR rama2, Authentication failure
    Jan 21 04:49:25 india passwd: pam_unix(passwd:chauthtok): password changed for rama2
    Jan 21 06:02:52 india passwd: pam_unix(passwd:chauthtok): password changed for rama2
    Jan 21 06:10:28 india unix_chkpwd[3150]: password check failed for user (rama2)
    Jan 21 06:10:28 india login: pam_unix(login:auth): authentication failure; 
    logname=LOGIN uid=0 euid=0 tty=tty2 ruser= rhost=  user=rama2
    Jan 21 06:10:30 india login: FAILED LOGIN 1 FROM (null) FOR rama2, Authentication failure
    Jan 21 06:39:54 india passwd: pam_unix(passwd:chauthtok): password changed for rama2
    

    Thanks, Ramachandra

    Reply
  13. 26.Find Last 50 Days Modified Files

    To find all the files which are modified 50 days back.

    # find / -mtime 50

    i think it should be -50 for last 50 days
    exact 50 days it should be 50

    Reply
    • @Axel,

      29. The command find / -cmin -60 will list the files status was last changed x minutes ago and,

      30. The command find / -mmin -60 will list files data or content was last modified x minutes ago.

      Reply
  14. Dear Sir,

    I want to search the hidden files for a particular duration of time.
    Ex..I need to search and list all the hidden files for the period Jan-10-2016 to Oct-10-2016.
    Please advise how to use the find command to search the above request.

    Reply
  15. Can any one help me for using find command I want remove .xml or .jasons all files but I can’t find any command. For example, I have directory /dev and with in sub directory’s and in sub directories I have may files but I want delete only .xml or .jasons files only.

    If any command to use one time delete files Recursively

    Reply
  16. thanks for the article, but there are a lot of other options, please explain them too.
    one the important is ‘-maxdepth’ and ‘mindepth’

    Reply
    • @Behrooz,

      Thanks for finding it useful, but trust me its not possible to explain each option in the one single article, to know more about each option just do man find to know about it.

      Reply
  17. how to search a file in the server and grep for a particular entry in that file and print only the output..?
    is there any way where we can hide all the search that is happening and display only the required result

    Reply
    • @Sindhu,

      You can use egrep to achieve the same, the below command will find a entry or string in a given file in Linux.

      # egrep -w 'entry or string' /path-to-file
      
      Reply
    • @Datta,

      Here is the command to multiple files using find command..

      # find . -type f \( -name "*.txt" -o -name "*.json" \)
      
      Reply
  18. Sir,

    We need help for linux (RHEL4) command FIND. How to tar todays ie., only current day (17-04-2016) files . Please give me examples.

    Thanking U sir,

    S Govardhan Raju
    T I R U P A T I

    Reply
    • @Govardhan,

      What you mean by “only current day” files? the whole system modification files in a particular day or any specific directory files you want to tar? Could you explain me more about your requirements so that I can help you out..

      Reply
  19. Sir

    We are happy to inform you that we are understanding linux commands with your examples easlly.

    Thank U very much Sir,

    S Govardhna Raju
    TIRUPATI

    Reply
  20. Thank you very much for providing valuable information.
    I have a query. How to find a file/directory having maximum size in particular path?

    Reply
    • @Sean,

      To exclude a directory from a find command while searching, use ‘prune’ option and -path switch as shown.

      # find . -path ./directory-to-exclude -prune -o -name '*.txt' -print
      
      Reply
  21. Hello everybody,
    Thank’s for all people who make some articles to benifit others.
    i have problem with the option prune of the find command, Could Someone explain thie option with some exmaples please ?

    best regards

    Reply
    • @Debra,

      The (.) means current working directory and I am using find command to search for files in current working directory, whereas / means whole filesystem.

      Reply
  22. Is there a way to display multiple results one page at a time? For example, if I execute: find / -name “grub*”, I get too many results and I can’t see the first ones, because they are gone from display

    Reply
  23. i create a file demo.txt
    after that run this command # find / -mmin -60 (Find Modified Files in Last 1 Hour)
    showing more file and how to find my file demo.txt
    tell me.

    Reply
  24. I have a question “if I want to find a particular word in whole server and save into in a single path” what is the exactly commant .

    Reply
    • @Sangam,
      Your question is not clear, but I think you want to find a particular word in all system files and then save that word to a different file? is this right?

      Reply
  25. Hi Ravi,

    I got result in SSH with one of find syntax.
    But I got too many results which I can not see all in SSH window.
    Can you suggest any syntax using which I can store all search result in any text file or something and I can have look at that file later on when needed?

    Reply
    • @Bharat,
      Use following example command to store all data about find command on a file.

      find / -name *.abc >> somefile.txt
      
      Reply
  26. You can also use this
    find . -type f -name “tecmint.txt” -delete
    instead of this
    find . -type f -name “tecmint.txt” -exec rm -f {} \;

    Reply
  27. The content is excellent at TecMint, but the pages cannot be saved/printed usefully. I save all web-urls in .pdf. Tecmint pages are useless to print.

    Reply
  28. quick question :-

    How do we find a file and then we rename (mv) the same file with one command
    Does -exec option work with it ?

    Any Examples ?

    Reply
  29. Dear Tecmints ,

    i understand that this works for one of the files to find apply the execute the action on those files

    $ find / -name “error_*.txt” -exec ls -lrathi ‘{}’ “;”

    but can you please provide examples on multiple files how do we do it ?

    Examples : – if there are “find_*.txt” “list_*.csv” and more

    Reply
    • Dear techmint ,

      I want to find and remove multiple files such as .mp3 or .txt, then use.

      But first i want to list it first , so i fire the below command.
      And i notice that when you try to find a pattern of files

      Example : “*.txt” , “*.tar” , “*.csv”

      as per the command All of them do not give me the out put
      Where as only the last pattern “*.csv” , gives me the output .
      Please advise , how i can get out put of : -“*.txt” , “*.tar” also in my find result

      find / -type f -name “*.txt” -o -name “*.tar” -o -name “*.csv” -exec ls -larthi ‘{}’ “;”

      1376260 -rw-r–r– 1 root root 118 Aug 17 2007 /usr/share/alsa/speaker-test/sample_map.csv

      [root@localhost ~]#

      Regards,
      Sunny

      Reply
      • find . -type f \( -name “*.txt” -o -name “*.tar” -o -name “*.csv” \) -print
        ./1.tar
        ./3.txt
        ./2.csv
        ./2.txt
        ./3.tar
        ./1.txt
        ./3.csv
        ./2.tar
        ./1.csv

        Reply
  30. I am very glad that you have describe the find command with examples. Thanks once again and Keep posted the linux related stuffs.

    Reply
  31. Hi.
    Great article.
    How to find executables files on RHEL4 and Solaris 9 and 10?
    I tried with
    find / -executable -type f and
    find / -perm /u=x,g=x,o=x -type f
    but it worked only on RHEL6.

    Thanks!

    Reply
  32. HI , How to see the files in particular date, Suppose I want to see Jan 18 2015 files among all the files. I tried +mtime not working

    find . -newermt 2015-01-18 -ls lrt

    above one is not working for me, Please suggest something

    Reply
      • Dera tecmint ,

        I have tried the above solution to find the files based on date , it does not seems to work, please assist

        find / -type f -newerat 2007-08-17 ! -newerat 2015-08-17
        find: invalid predicate `-newerat’
        [root@localhost ~]# date
        Fri Aug 7 11:25:10 IST 2015

        Reply
        • Dear techmint,

          I have tried the below as well does not seem to be working

          find -newerat “Mar 01 2008” ! -newerat “Mar 01 2014”
          find: invalid predicate `-newerat’
          [root@localhost ~]# find -newermt “Mar 01 2008” ! -newermt “Mar 01 2014”
          find: invalid predicate `-newermt’

          i am Unix Linux system .

          uname -a
          Linux localhost.localdomain 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:02 EDT 2007 i686 i686 i386 GNU/Linux

          Regards,
          Sunny

          Reply
  33. Hello sir,

    I am trying to find files in Linux using the find command. I need to search in an nfs mounted filesystem to list all the files owned by a certain user. Example:

    drwxrwxr-x 2 afsharf staff 126976 Oct 9 14:20 trevor/
    -rw-rw-r– 1 afsharf staff 22947599 Oct 9 08:52 troj.out
    -rwxr-xr-x 1 camachoe staff 11752 Jun 25 2013 runtnav_beta_h*
    -rwxr-xr-x 1 camachoe staff 11648 Jun 25 2013 runtnav_h*

    I would like to find files owned by “camachoe” in the current and sub- directories . Any idea how to do that using find command? this is an nfs mounted filesystem.
    Thank you in advance.

    Reply
  34. Hi Sir,

    Is there a way to use find/locate on a list? example:

    while read line
    do
    if locate “$line”
    then
    echo “Y: $line”
    else
    echo “N: $line”
    fi

    done < $1

    on my case, this always returns N: (line), I think the locate command reads my variable as $line literally, also tried to use find command here, same result. any thoughts?? thank you in advance :)

    Reply
    • Bharath, I think you should try this command.

      # find /your-path -maxdepth 1 -type f -name "*.txt" > filestobedeleted.txt
      
      Reply
  35. Hello sir,i am working on migration project,i have a few question sir how to migrate all users home directory data to new linux system using bash shell script.will u please provide me any script or idea for that.thanx in advance.

    Reply
    • Dear Pravin,

      We surely provide you a step-by-step instructions on how to migrate all Linux users from one server to another server using some command line tricks. Till then stay tuned for the updates.

      Reply
  36. You know, with HTML you can turn a table of contents into links that take a reader straight to each section … just sayin’.

    Reply
  37. this is quite useful page and I used many of these commands after seeing your page .

    thank you so much for such a wonderful collection of the commands with example.

    All the best to you

    Reply
  38. how can i use this two as single command?
    find -name ‘*.jpg’ -mtime +7 -exec jpegoptim {} \;
    find -name ‘*.jpg’ -mtime +7 -exec chown www-data:www-data {} \;
    thanks :)

    Reply
  39. How can we find the files inside a directory concerning date range and remove them.?

    Example: I want to remove the files created between “1st Jan 2012 8 AM” and “5th Jan 2014 10 PM”

    Reply
    • To find and remove files within a specific date range in a directory, you can use the find command in combination with the rm command as shown:

      find /path/to/directory -type f -newermt "2012-01-01 08:00:00" ! -newermt "2014-01-05 22:00:00" -exec rm {} \;
      
      Reply
  40. Locate User “username” regular files and save as /tmp/backup

    find / -user username -type f -exec cp -a ………………. please complete this … needed earlier

    Reply
  41. 35. Find all .mp3 files with more than 10MB and delete them using one single command.

    # find / -type f -name *.mp3 -size +10M -exec ls -l {} \; — but there is not command to delete the files.

    1) how to list files in range (A001 to A090)suppose if there are log file which names are
    starting with log.A001 to log.A00nth or may be more .
    2)list out the files created in a certain date.
    3)search the string pattern “xyz” in all files and count how many times the string is present in all the locations.

    please help

    Reply
  42. Can you explain this option to me, I am new to the command line – still learning.

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

    the symbols {} and the \

    I am a bit confused, any help/advice would be great.

    Reply
  43. hi! glad i found your site and the informative articles. question re: “35 Practical Examples of Linux Find Command”:
    in # 3. ‘ find /home -iname tecmint.txt’, what is proper way to filter results of this command such that the Uppercase results are sorted from the lowercase results?
    ex.:
    …….
    Techmint.com
    Techmint.com1
    Techmint.com2 …….

    techmint.com
    techmint.com1
    techmint.com2, etc., etc., etc.

    Thanks again for all the good info. Have A Healthy, Prosperous Day!
    —rob

    Reply
      • While this post is quite old. May I make two suggestions. 34) instead of running -exec rm -rf, the less cpu taxing option would be to add -delete to find. Would be good to note and using -print first to confirm what is being deleted or just the find command piped to head to confirm some of the files is a good step before using any additional command/options that would delete.

        35) Pretty much the same as 34 as it is missing the deletion option.

        Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.