Find a File by Name in UNIX, Solaris, or Linux
Using the find command, one can locate a file by name.
To find a file such as filename.txt anywhere on the system:
find / -name filename.txt -print
Recent operating system versions do not require the print option because this is the default. To limit the search to a specific directory such as /usr:
find /usr -name filename.txt -print









snarfel said on October 22, 2008
so, i get a bunch of “Permission Denied” notices for directories that my current user account can’t access. is there a way to suppress these?
Quinn McHenry said on October 22, 2008
Yeah, totally. Normal output goes to “standard output” which can be redirected with normal measures. It’s actually a nice thing that those messages are sent to “standard error” so you can redirect those but keep the more interesting responses.
find / -name something 2> /dev/null
venkata sudheer said on November 17, 2008
try this # find -name -print
Jesse F. said on January 8, 2009
His problem is is that he doesn’t have permissions to view a lot of the files ‘find’ uses. Here’s a few options:
If you don’t have root permission, then you can supress error messages like so: ‘find -ignore_readdir_race /parent/path/here -name file_name.txt’
Or if you can get permission, then: ’sudo find /parent/path/here -name file_name.txt’
yay!
Srikantakumar said on June 22, 2010
when I am excuting the below command, getting the file name with ./ prefix before file name which i don’t want (like test2 only not ./test2). any suggestion….
$ find -name “test*” -type f -print
./test2
./test3
./test1
Goldcd said on June 29, 2010
Try
find / -name filename.txt -print 2>/dev/null
Rani Sahoo said on November 12, 2010
I can use locate filename to get the file with path.