Welcome, Guest. Please login or register.
April 24, 2014, 10:46:38 AM
Home Help Search Calendar Login Register
Show unread posts since last visit.
News: Let Pardus-Anka become #1: Pardus-Anka Bug ReportPardus-Anka World Google+ | The Pardus wiki  | Visit Pardus-Anka official website  | Register as forum member?  Email the moderator!

+  Pardus Worldforum
|-+  Assistance
| |-+  Pardus for beginners
| | |-+  Locate & updatedb
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Print
Author Topic: Locate & updatedb  (Read 1687 times)
Caesar Tjalbo
Pardus fellow craft
**
Posts: 33


View Profile
« on: October 27, 2007, 21:09:17 PM »

I can't find ( Tongue ) locate or updatedb, not even in the man pages. Am I doing something wrong or have they been excluded for a reason? Is there an alternative?
Logged
DANHO
Pardus Master
***
Gender: Male
Posts: 187


Pardus SF


View Profile
« Reply #1 on: October 27, 2007, 22:04:24 PM »

Im not sure about "updated b"  or even "updateb", But
If you want to update your pardus operating system or see what packages are available then simply, click Tasma>System>Package Manager
Or simply click the little cat in the box icon.
Hope this helps.

dev/.udev/db
var/db

.
« Last Edit: October 27, 2007, 22:18:15 PM by DANHO » Logged
DANHO
Pardus Master
***
Gender: Male
Posts: 187


Pardus SF


View Profile
« Reply #2 on: October 27, 2007, 22:22:14 PM »

OK, find and click "File Manager" its in "more applications.
su in your root password and find these two(2) system folder "dev" and "var"
here you should find db related files.











Buenas Suerte.
« Last Edit: October 27, 2007, 22:23:57 PM by DANHO » Logged
Caesar Tjalbo
Pardus fellow craft
**
Posts: 33


View Profile
« Reply #3 on: October 28, 2007, 01:02:49 AM »

Hello DANHO,

Thank you for answering but I'm not sure we understand eachother. I'm referring to the 'locate' command. For finding files it's like 'find' except 'find' searches the filesystem and 'locate' searches a database. 'Locate' therefore is faster but 'find' looks at the actual situation where 'locate' looks at the situation stored in a database. 'Updatedb' is the command to update the 'locate' database.

I don't know where those commands come from, perhaps they're distro specific, but I had them on other distros I've used. I ask my question because I don't know if there's a reason why I can't find them. I've checked pisi with 'list-available' and I have the 'findutils' ("GNU utilities to find files") package installed. Does anyone else have locate and updatedb, am I doing something wrong or is there "a Pardus way" to finding files?
Logged
DANHO
Pardus Master
***
Gender: Male
Posts: 187


Pardus SF


View Profile
« Reply #4 on: October 28, 2007, 01:20:26 AM »

Its somewhat over my head i know.
Maybe try "slocate" or "kerry beagle"
Or sure enough, someone with a better understanding will respond.
« Last Edit: October 28, 2007, 01:25:45 AM by DANHO » Logged
Kavani
Guest
« Reply #5 on: October 28, 2007, 11:03:16 AM »

I'm not sure if the locate command is in Pardus, but try it as root or /sbin/locate  ?
Logged
Caesar Tjalbo
Pardus fellow craft
**
Posts: 33


View Profile
« Reply #6 on: November 03, 2007, 14:36:30 PM »

As root:
Code:
# time find / -iname locate

real    2m1.746s
user    0m0.800s
sys     0m2.402s
Code:
# time find / -iname slocate

real    0m4.454s
user    0m0.535s
sys     0m0.740s
What this tells me is: 1. I don't have (s)locate, 2. 'find' uses some sort of caching so subsequent searches are a lot faster (but you see why a database approach is useful).

I might write my own 'locate' for fun and exercise but I'm still curious why it's not included with the default install. Can a Pardus engineer perhaps enlighten me? It's not really an issue, merely curiosity, but I'll explain why I'm so surprised:
Code:
# pisi la | grep findutils
findutils       - GNU utilities to find files
(it's green in the console, indicating it's installed)

According to http://www.gnu.org/software/findutils/:
Quote
find - search for files in a directory hierarchy
locate - list files in databases that match a pattern
updatedb - update a file name database
xargs - build and execute command lines from standard input
find and xargs are present (try "find / -name find" if in doubt  Cheesy), locate and updatedb are not (not even in the man pages). Why, oh why? Huh? Grin

(locate or slocate? I found slocate is "secure" locate; when updatedb is run as root, the filenames/locations of the entire filesystem are stored in a database. Running locate as non-root would then display files in directories where the non-root user doesn't have read-permission on. slocate prevents those entries to be seen. It's probably a distro-specific thing how locate behaves or what it's called.)
Logged
DANHO
Pardus Master
***
Gender: Male
Posts: 187


Pardus SF


View Profile
« Reply #7 on: November 04, 2007, 05:12:36 AM »

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.

« Last Edit: November 04, 2007, 05:22:21 AM by DANHO » Logged
Caesar Tjalbo
Pardus fellow craft
**
Posts: 33


View Profile
« Reply #8 on: November 04, 2007, 14:38:52 PM »

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.  Wink

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 pornicture collection.
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.
Code:
# find / -name * | wc -l
336547
of which are 'mine':
Code:
# find /home -name * | wc -l
5345

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 Grin 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.
« Last Edit: November 05, 2007, 01:06:29 AM by Caesar Tjalbo » Logged
DANHO
Pardus Master
***
Gender: Male
Posts: 187


Pardus SF


View Profile
« Reply #9 on: November 05, 2007, 21:25:56 PM »

find' searches the filesystem and looks at the actual situation.
locate' searches a database and looks at the situation stored in the database.

"Updatedb" is the command to update the 'locate' database.

So before running locate, you want to run updatedb to update the internal database. Cool

« Last Edit: November 05, 2007, 21:32:24 PM by DANHO » Logged
Pages: [1] Go Up Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!