How To Use Find and Locate to Search for Files on a Linux

Linux distributions are well known for their command line interface. But it makes difficult to find a file in one folder. Unlike Windows/Mac, most of the system admins prefer the nongraphical interface.

So how to find a file in Linux distributions?. Let’s use some commands as we use locate command in Linux for finding files in directories.
It will recursively find files in Linux distribution

Finding by Name

The simplest method is finding file by name
To find a file by name, type:

find -name "filename"

Find the file by pattern

find -name "*.conf"

Above will be case sensitive, meaning “Filename” will not be same as “filename”

To find a file name, but without case sensitive:

find -iname "filename"

If you want to exclude some of the file patterns from the search, just use the below command.

find -not -name "file_to_avoid"


Finding by Type

You can search based on the type of the files in Linux distro.

Synatx will be

find -type type_descriptor query


find / -type f -name "*.conf"

Some of the most common descriptors that you can use:

  • f: regular file
  • d: directory
  • l: symbolic link
  • c: character devices
  • b: block devices


Editorial Staff

Editorial Staff at tutsplanet is a dedicated team to write various tutorial articles.