How to use find command in Linux

Share It!

The Linux Find Command is one of the most valuable and convenient command in Linux systems. It can search the whole filesystem to find files and directory as indicated by the search criteria you determine. The find command is accessible on most Linux systems by default so you don’t need to install any packages. The find command is a key one to learn, on the off chance that you need to get super productive with the command line on Linux.


See Also:

  • Some more examples of find command
  • Finding Files by Name

    If you want to find the file whose name is technical.txt in a current working directory, run following command:

    # find ./ -name technical.txt

    If you want to find all the file who name is starting with technical, run following command:

    # find ./ -name technical*

    Find all the files whose name is support.txt and contains both capital and small letters in /tmp directory.

    # find /home -iname support.txt

    If you want to find all files and want to ignore file with a specific pattern, you can invert the search with “-not” or “!”. If you use “!”, you must escape the character so that bash does not try to interpret it before find can act:

    # find -not -name technical.txt


    # find \! -name technical.txt

    Find all the files under /tmp directory with name technical.txt.

    # find /tmp -name tecmint.txt

    If you want to find all the file under /tmp directory who name is starting with technical, run following command:

    # find /tmp -name technical*

    Search files into multiple directories.

    # find /opt /usr /var /etc -name support.txt -type f

    Find files with different extensions or patterns.

    # find . -type f \( -name "*sh" -o -name "*xml" -o -name "*html" \)

    Finding by Type

    You can specify the type of files you want to find with the “-type” parameter. Use following command:

    # find / -type f technical.txt

    Some of the most regular descriptors that you can use to indicate the kind of document are here:

  • f: regular file
  • d: directory
  • l: symbolic link
  • c: character devices
  • b: block devices
  • We can search all the files that end with “.php”.

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

    To find all hidden files, use below command.

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

    Enjoy it!

    Leave a Reply

    Your email address will not be published.