2009-06-10

Finding Files on Your Computer

It happens to all of us, we forget where files are saved. The good news is that with the locate command is a great way to find files on your computer. Before we can use the locate command, we've got to build an index of the files on our computer, which is easy enough: we just need to use the updatedb command:

# updatedb

It is a good idea to periodically run the updatebd command to keep your index current when you go to search for files. All you need to know to search for files is to know all or part of the file name. For example, if you couldn't remember where the xorg.conf file is saved, you can search for it like this:

$ locate xorg.conf

Here is an example output of the above command:

$ locate xorg.conf
/etc/X11/xorg.conf
/usr/share/man/man5/xorg.conf.5.gz
/var/lib/x11/xorg.conf.md5sum
/var/lib/x11/xorg.conf.roster
$

Alternatively, if you were looking for the xorg.conf file, but could only remember that the filename started with xorg., you could search for it like the following:

$ locate /xorg.
/etc/X11/xorg.conf
/usr/share/X11/xkb/rules/xorg.lst
/usr/share/X11/xkb/rules/xorg.xml
/usr/share/man/man5/xorg.conf.5.gz
/var/lib/dpkg/info/xorg.list
/var/lib/dpkg/info/xorg.md5sums
/var/lib/x11/xorg.conf.md5sum
/var/lib/x11/xorg.conf.roster
$

There is more that can be done with the locate command, but this has covered about 98% of the times I've used it. I'll probably cover some more of these features in a later post. Another thing that is useful is to schedule the updatedb command via cron, which we'll be discussing next time.

See you next time

No comments:

Post a Comment