Click to See Complete Forum and Search --> : Search command


LuvLinux
06-25-2001, 12:57 PM
Hello,

What is the command for linux red hat to find a file or directory on the box?

Thanks

LL :rolleyes:

Craig McPherson
06-25-2001, 01:09 PM
You can do a full search like this:

find -name filename /

That's fairly slow, though. Linux keeps in index of all files on the system for fast searching:

locate filename

That'll be much faster, but it won't actually search your hard drive -- it'll search a snapshot of your filesystem as it was the last time the database was updated. The database should be updates daily or weekly via a cron script. So it won't find files that were created in the past few hours, and files that were deleted in the past few hours will show up even though they're not there anymore.

bdg1983
06-25-2001, 04:14 PM
Let's say you just installed a package and you want to find a file that was installed with the package. Just update the locate database manually ( updatedb ) and then you can find the file with 'locate filename'.