I wonder why aren't there any tool that enable one to find files on his harddisk very rapidly like "search everything" does .Just type a part of the file name and all files containing the keyword will show up instantly . Isn't it possible to design a program to record the names of all files in some directory in a database so that you can search the database quickly for file names ?
Asked
Active
Viewed 3.4k times
23
-
A minor nitpick, but it might help you understand the system better. In general, filesystems don't directly support file searching or creating indexes. The job of the filesystem is to store files. Searching and indexing is done by various utility programs. It's done this way because simpler filesystem=smaller chance of bugs and it lets the user configure the level of index-building and which areas should be the targets. – Perkins Jul 28 '16 at 17:29
2 Answers
13
Run sudo updatedb
and locate [ filename or part ]
updatedb
updates the index database.
If you want to locate a program, run whereis [ program name ]

Scott Severance
- 14,056

Gufran
- 1,696
-
1Nice, but how to make locate search in some specific directory in linux mint ? – hvjkjdtmkgh Nov 07 '12 at 08:58
-
well for that purpose you can use
find
command, use it like thisfind [path to directory] | grep "file name or part"
This will search recursively so you can just search inside the base directory and it will automatically look for the file inside any sub directory. – Gufran Nov 07 '12 at 09:02 -
-
Thanks , but can you give me an example ?I'm completely new to linux .In windows ,you write D:\foldername\ etc What's the equivalent in linux? Also ,does this tool has a GUI so that I can open the file directly ? – hvjkjdtmkgh Nov 07 '12 at 09:29
-
utilities like
locate
orfind
do not have GUI built in, you can use a third party tool likecatfish
. To install the tool you can search forcatfish
in software center or run this commandsudo apt-get install catfish
. After installing this you can open the program from Unity Dash. regarding the File structure in linux, there is noC, D
Drives, all the partitions are mounted as directory inside root, that is/
(back-slash). so everything goes directly inside/
, like your Home directory (same as your user directory in windows) is located inside/home/
– Gufran Nov 07 '12 at 09:46 -
for an example, open terminal by pressing
CTRL+ALT+T
and typesudo updatedb
and enter password. Then typelocate firefox
, this will show any directory or file having 'firefox' in its name. Then again runwhereis firefox
. This will show the path to directory where firefox is installed – Gufran Nov 07 '12 at 09:51 -
Never knew it! Guy, I love you sooo much, I was already sick of manual searching all the missing headers in my system(that is a whole deal when you know only the name but nor an exact include directory). – Hi-Angel Aug 29 '14 at 06:38
-
@Gufran rather than calling a blanket find and piping the results to grep, use find's built-in search parameters. It's more efficient and lets you filter by more than just name. If you need to search for partial filenames you can use standard shell wildcards as long as you enclose the search terms in quotes. i.e. find /home -iname "*importantdoc*" for a case-insensitive search for any file with "importantdoc" in its name. – Perkins Jul 28 '16 at 17:32
-
Catfish does not work properly: it claims that it is using updatedb / mlocate, but it is not: Searches are not instantaneous (which you get when using updatedb) but it takes a long time to find files, which is not indexed and not usable for large file systems. – Markus Bawidamann May 18 '20 at 22:21
6
If you are looking for file names only, it allready does this, it is called locate
For more advanced searching you can look at tracker: https://wiki.ubuntu.com/Tracker (see also this question: What are the alternatives to OS X's Spotlight? )
More options you can find here: https://help.ubuntu.com/community/FindingFiles
-
-
That's another question, but you can find the answer here http://serverfault.com/questions/313733/how-do-i-use-the-locate-command-within-a-specified-directory :) – Nanne Nov 07 '12 at 08:59
-
but that finding files link on help.ubuntu is quite a good description of your choices it seems? – Nanne Nov 07 '12 at 09:00
-
@hvjkjdtmkgh: See my comment on Gufran's answer for how to search a specific directory. – Scott Severance Nov 07 '12 at 09:15