Locate: Difference between revisions

From Hackepedia
Jump to navigationJump to search
Frankk (talk | contribs)
No edit summary
 
m added "executable" to "which" and moved below "locate"
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:


Trying to locate a file, if you're lucky you can try
Locate searches for every instance of the file in your locate database, in this example we'll try to find "bash":
# locate bash
/usr/jail/usr/share/zoneinfo/Africa/Lubumbashi
/usr/local/bin/bash
/usr/local/bin/bash2
/usr/local/bin/bashbug
[snip]


  $ locate [[variables|$file]]
Trying to locate an executable file, if you're lucky you can try
 
  # which [[variables|bash]]
/usr/local/bin/bash
 
Which will search your [[$PATH]] for an executable of the same name:
 
Whereis locates source/binary and manuals sections for specified files, searching in a list of standard places:
 
# whereis bash
bash: /usr/local/bin/bash /usr/local/man/man1/bash.1.gz /usr/ports/shells/bash
 
 
== Updated your locate database ==
 
On FreeBSD:
 
# vi /etc/locate.rc
 
to see you options. i.e. You might want to add /usr/ports to PRUNEPATH and then:
 
# /usr/libexec/locate.updatedb
 
You can see the database stored at /var/db/locate.database.
 
On Debian GNU/Linux:
 
--prunepath is one of the many options found in the [[Manual]], then rebuild your database:
 
# /usr/bin/updatedb
 
You can see the database stored in /var/cache/locate/locatedb.

Latest revision as of 11:07, 8 February 2007

Locate searches for every instance of the file in your locate database, in this example we'll try to find "bash":

# locate bash
/usr/jail/usr/share/zoneinfo/Africa/Lubumbashi
/usr/local/bin/bash
/usr/local/bin/bash2
/usr/local/bin/bashbug
[snip]

Trying to locate an executable file, if you're lucky you can try

# which bash
/usr/local/bin/bash

Which will search your $PATH for an executable of the same name:

Whereis locates source/binary and manuals sections for specified files, searching in a list of standard places:

# whereis bash
bash: /usr/local/bin/bash /usr/local/man/man1/bash.1.gz /usr/ports/shells/bash


Updated your locate database

On FreeBSD:

# vi /etc/locate.rc

to see you options. i.e. You might want to add /usr/ports to PRUNEPATH and then:

# /usr/libexec/locate.updatedb

You can see the database stored at /var/db/locate.database.

On Debian GNU/Linux:

--prunepath is one of the many options found in the Manual, then rebuild your database:

# /usr/bin/updatedb

You can see the database stored in /var/cache/locate/locatedb.