Download PDF
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.
user@user-desktop:~$ pwd
/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/”
user@user-desktop:~$
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(1)
FIND(1)
NAME
find – search for files in a directory hierarchy
SYNOPSIS
find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path…] [expression]
DESCRIPTION
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 …. ….
1903 Wright Place, Suite 120
Carlsbad, CA 92008
Toll-Free (877) 633-7743
Email customercare@medsphere.com