How to Search for a File in Linux?

How to search for a file in linux?

There are different methods for locating a file in Linux. A few methods are listed below.

1. 'Find' command

'find' searches for files in a directory hierarchy.


To search for a file, login to your linux server and open a terminal ( Applications >> Accessories >> Terminal) and type the following command.

find [path...] [expression]

eg: find . -name "filename"

. ==> current folder (search for a file in current location)
name ==> expression
filename ==> name of the file

To search for a file in the whole system.

find / -name "filename"

This will search the whole system for any files named "filename" and display their pathnames.

To find a file by name, but ignore the case of the query, type:

find / -iname "filename"

To find a file in a particular location specify the path.

find /path [expression] "filename"

eg: find /home -name "filename"

This will search the "home" folder (folder you are specifying. Here "home" folder)

for any files named "filename" and shall display it.

2. 'Locate' command

The locate command finds files by name.


locate [OPTION]... PATTERN...

eg: locate "filename"

Add '-i' option to perform a case-insensitive search.

locate -i "filename"

3. 'which' command

Locate the executable file associated with a given command. 'which' command does not follow symbolic links.


which -a [filename]


-a    Print all matching pathnames of each matching filename.

eg: which sh
Locates the pathname of the file which would be run if the sh command were executed. On most systems, this will output:

You can also search for a file in Linux server from:
1. "Start" button in main toolbar -> "Search" -> "Search for files"
2. Enter the location (folder) and "filename".
3. Click 'find' button.

Last update:
2016-06-16 01:55
Sherin George
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Records in this category