Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Location: Farnham, Surrey, UK (Chile until Dec 2011)
Distribution: Fedora Core 14
Posts: 32
Rep:
Locate command to include the external hard drive
Hi Everyone
I normally use the "locate" command to find files that I have on my local drive. However, if I wanted to do this for an external drive, how would I go about this?
From what little I know about Linux, I'm guessing that it creates a reference file from which it performs the search when the command is typed. If I'm right this is updated at a given interval or when "updatedb" is used?
As the external hard drive is not always mounted is it best to create another of these reference files and have a different command (e.g. locateext) or something? Or is it best to add the external hard drive's location to the list of files that get added with updatedb.
I'm running Fedora 11.
Sorry if I'm getting the wrong end of the stick somewhere or I'm not very clear! If you are unsure of anything then ask me!
Look in /etc/sysconfig/locate. Remove the directory from prunepaths. You may need to change an entry like /mnt/ to prune the directories of /mnt/ to exclude.
Suppose you have /mnt/dirA, /mnt/dirB, and /mnt/dirC. Change the entry for prunepaths to /mnt/dirB /mnt/dirC. Then /mnt/dirA will be included.
If you don't have an /etc/sysconfig/locate file, then then read your daily cron script that runs updatedb nightly. It probably reads a config file at the top of the script.
What I suggest is running locate with two different database files. You can specify the name and location of the database file when you run updatedb and specify the appropriate file when you use locate. Specify what partitions or directorys you want excluded on the command line. You can create an alias or a script for these.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.