Hey Caesar, So you're saying updatedb is a utility that allows us to update internal files like named.ca and named.conf in our bind folders.
No, it has nothing to do with Bind, it's much more trivial. The command 'locate' is used to find a file on a filesystem, your harddisk for example. Locate doesn't actually read the filesystem but reads a database where it finds filenames and locations to those files. Initially that database is empty so before you can use locate you have to fill the database with the 'updatedb' command. Additionally, when something changes on your filesystem, you rename, create or delete a file for example, you need to run updatedb to make sure the locate database contains the actual situation. Typically, updatedb is set as a cron-job to run daily.
So then, what's the relevance?
Say you're looking for a file on your harddisk. You know (part of) the name of the file but not where it's stored. Some examples:
- you've installed an application and you want to edit the config file but you don't know what the directory of the application is and hence not where to find that file,
- you've got a tune in your head, you don't know the artistname or the album, only that the song has a specific word in the title (and you don't have a player like Amarok installed which allows you to search for songs in its database),
Now, in the Pardus menu there's an entry called "Find Files/Folders", alternatively you can use Konqueror or Dolphin's find function. But being 1337 Linux hackers, we've got a console open anyway so we might aswell use it and type the commandos.
The most straight forward way is to use 'find'. Find walks through the filesystem, starting at the directory you provide and looks for filenames which fit the expression provided (see the manpage for find). Find looks at _every_ file and directory and returns filenames that matches the search expression. The time this takes depends how fast your harddisks are and on how many files there are in the path to search: a standard system consists easily of several thousands of files and dozens of directories, even without an extensive mp3 or p
Meaning that if you're looking for an mp3 and all your mp3s are in the directory /home/user/Music, then you can limit the search considerably but if you've no idea where to look then the starting point needs to be the system root directory /. From the example in my previous post, I gather that it takes over 2 minutes to do a full search, and that's with hardly music and images present but my disks are slow.
The following command searches everything for everything but instead of displaying all the filenames, it counts how many lines are outputted. Normally, every line is a file but many files get 2 lines: "/home/<user>/<file>" is equal to "/mnt/<harddisk>/<user/<file>" but both are displayed. Anyway, even with the number divided by 2 it's a large amount of files.
# find / -name * | wc -l
of which are 'mine':
# find /home -name * | wc -l
From what I've seen, 'find' takes a long time the first time it's run but is near instantaneous on subsequent runs. That is comparable with 'locate': 'updatedb' takes a few minutes to populate the database and locate is then near instantaneous. The difference is that I can run updatedb when it's convenient and it also uses a smart mechanism to update only those database entries that have changed; I think it's faster if there aren't many changes to the filesystem. I'm a bit surprised with the way find works in subsequent searches but I imagine locate is faster than find since it can have an index on the database.
Hence I'd like to hear from the Pardus package maintainer for GNU-findutils; I don't know enough about the background. I can look at the sourcecode for findutils but I'm afraid that's just it: look at it, I think it's so complicated that I won't understand what I'm looking at. It's probably not written in Python
or very accessible C, I guess it's highly optimized and specialized code, and will go way over my head.
Edit: for those interested, Linux Format December 2007 has an article about searching with many practical examples of how to use find.