How to search entire hard drive for a file?

Solution 1:

A simple find / -type f -name "" would do the trick if you know exact filename.

find / -type f -iname "filename*" if you want to match more files (ignore case).

Avoid -type option if you want to search for directories etc. See manual of find for more information. To see the manual, issue the command:

man find

Solution 2:

You could also use locate to look for commands. Why do people use locate if find does the job? Because locate is much faster than find since it just searches through database(s) of indexed locations to find your file/regex.

Examples:

locate some-file.avi searches through database(s) of almost every file on the disk for a file called "some-file.avi".

locate -i "some-file.avi" will ignore the case of the file you are searching for.

locate -i "*.txt" will display a list of locations of all the files with **.txt* extension on your system.

man locate for more info on the file.

You might need to run updatedb first to ensure the index database is up to date, otherwise, 'locate' might not return what you are looking for.