There are many times when we need to find files in Linux to solve a current issue. Sometimes we need to find a certain file that may have been scanned while troubleshooting a webdav problem, etc. You can use the find command to search and find a file.find [directories] [expression]
I created a directory called “/opt/findme” and at that location touched a file called “samplefile.here”. From my home directory I did a search starting from the “root” directory using the find command to locate that file.
/home/user – shows my current location, my home directory
You will need to use admin privileges (sudo) to do the search because you won’t have permission to look through the /opt directory otherwise. After “sudo find”, you can specify “/” to start searching from the root directory. Then to specify a search by name you would use, “- name”. You can put a pattern in case you aren’t sure of the complete filename (you can use wildcards including ‘?’), but in the example below the extension is “here” so we used “*.here” and then “–print”, to show the location.
user@user-desktop:~$ sudo find / -type f -name *.here -print
/opt/findme/samplefile.here – the results “samplefile.here” in “/opt/findme/”
You can also look at the “man page” for find to see what options are available for this command.
user@user-desktop:~$ man find – to display help for the find or any other command
find – search for files in a directory hierarchy
find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path…] [expression]
This manual page documents the GNU version of find. GNU find searches
the directory tree rooted at each given file name by evaluating the
…. …. …. …. …. and so on …. ….