i run a Ubuntu box on my PC, and the Ubuntu is install as dual-system, i mean the PC have a Ubuntu and a WIN7.

So i use the locate command to find a file, it often list a lot files existing in windows system , for example, it usually list some content under /host/.. , those is under WINDOWS. thus not only time consuming, but also make me not easy find what i want.

My question is :How to set the parameter of locate command and avoid such a problem? make the locate cmd just find files under linux directory?


edit /etc/updatedb.conf

sudo nano /etc/updatedb.conf

find the line

PRUNEPATHS="/tmp /var/spool /media"

add in host

PRUNEPATHS="/tmp /var/spool /media /host"

save your changes, then run

sudo updatedb
sudo updatedb --prunepaths='/host'

This might take a little while to run.

According to man locate, and man updatedb, locate uses a database to find files. This database is modified using updatedb. The --prunepaths argument stops locate from looking along the paths listed. (you can list multiple paths within the single quotes, separated by spaces, and leaving off the trailing slashes)

If you want to search on /host later, run sudo updatedb with no arguments.

  • that is a temporary solution, updatebe will overwrite the result next time it runs. – Panther Jan 4 '14 at 4:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.