LOCATE FIND AND WHEREIS
From: John T. Douglass
<john.douglass@anlw.anl.gov>
Also see UPDATEDB
Just to point out the differences between locate, find, and
whereis:
whereis: will search only particular paths to find
binaries and or manpages. The manpages tells you where whereis
looks.
locate: locate uses a database created by an updatedb
to efficiently locate files. Works great, assuming your
database is updated often enough to be reasonable upto date.
Most boxes using locate have the updatedb occuring in cron.
find: find is perhaps one of the most powerful commands
there is. For just locating a file/program of a particular
name, it'll definitely be slower than locate or whereis becuase
it will search each and every path recursively from it's start
point. But for instance tell me how to use locate or where is
to things like the following:
to find all directories on the system whose permissions of
777
find / \( -type d -a -perm -777 \)
-print
find all core files in home directories and remove
them
find /home -name core -exec rm {}
\;
find all files owned by a particular user no matter whose home
directory they are in:
find /home -user <usernmae>
-print
find all files that have been modified (or had their
modification time changed) in the last 30 days:
find / -mtime -30 -print
find all trc files older than 30 days and remove:
find /dirpath \( -name \*.trc -a -mtime
+30 \) -exec rm {} \;
And the list goes on. Yes find will recursively descend the
path each time looking at every file to determine whether it
matches the criteria but there are a lot of times that this is
exactly what you
want. As an experienced system administrator I have learned
the power of the find command and have found it to be one of
the single most important commands I know.
|
|
|