How To Find Files And Folders In Linux.
This is “find” command tutorial.
The command find will search location you specify for files that match the supplied search criteria.
The search is recursive which means that find will search the location that you specify and all the subdirectories that it find in there.
If you type
# find –help
You’ll see the help text which starts by listing:
Usage: find [path...] [expression]
Default path is the current directory; default expression is -print
expression may consist of: operators, options, tests, and actions.
To simplify it, look at it like this.
find path criteria action
Examples:
# find / -name httpd
Will located any file or folder named httpd searching recursivley from the root path and downwards.
Depending on your configuration, that might take a while since you are searching the whole OS installation.
On my Cent OS server the output looks like.
/var/log/httpd
/var/lock/subsys/httpd
/usr/include/httpd
/usr/lib/httpd
/usr/sbin/httpd
/etc/logrotate.d/httpd
/etc/rc.d/init.d/httpd
/etc/sysconfig/httpd
/etc/httpd
Please note that if find doesn’t locate any matching files, there will be no output.
You also will see an error message on each directory that you don’t have access permissions to.
You can specify as many places as you want to search in, for example:
# find /var $HOME /bin -name history
This will search /var, your home directory and /bin for files name history.
You can use wildcards in the file name argument.
# find / -name mail\*log
This will search the whole system for any file with a name that begins with mail and ends with log.
Another way of specifying wildcards in your search is
# find / -name ‘*.log’
This will find all the files in your system that have the .log extension.
If you want to find more than one type of files, use the following:
# find / -name ‘*.log’ -o -name ‘*.pid’
This will find all the log and pid files on your system.
To find a list of the directories, use the -type specifier. Here’s an example:
# find . -type d
This is a basic tutorial, as find is very customizable and powerful command.
Please refer to the full usage of find by typing.
# man find
In your shell.

February 18th, 2009 at 12:07 pm
Nice cheat sheet sir this will definitely come in handy!
February 18th, 2009 at 12:19 pm
Thank you.
June 15th, 2009 at 3:58 am
Hi, interest post. I’ll write you later about few questions!
March 2nd, 2010 at 12:31 pm
Wonderful!
Examples given are describe in the easiest way that a lay man like me can understand easily and use it.
Thank you.
Pankaj Mukherjee
March 11th, 2010 at 10:32 pm
What theme is this? Can’t wait to start my own blog. watch the hurt locker online
March 27th, 2010 at 3:43 am
This blog makes me want to start my own blog.
April 11th, 2010 at 7:37 am
I have read a few of the articles on your website now, and I really like your style of blogging. I added it to my favorites web site list and will be checking back soon. Please check out my site as well and let me know what you think.
April 17th, 2010 at 5:18 pm
Awesome post!
April 19th, 2010 at 6:38 am
Another Great write up, I will be sure to save this in my Digg account. Have a good evening.
May 17th, 2010 at 10:43 am
Very informative post. Thanks for taking the time to share your view with us.
June 1st, 2010 at 9:17 am
I just book marked your blog on Digg and StumbleUpon.I enjoy reading your commentaries.
June 7th, 2010 at 8:36 am
With the compliments of the season.