# File system search

Related articles

- Core utilities

This page provides a general overview of the utilities available to search your filesystem.

## find

find might seem a little counter-intuitive at first. One would probably expect a find command to take as argument a file name and search the filesystem for files matching that name. For a program that does exactly that see #locate below.

Instead, find takes a set of directories and matches each file under them against a set of expressions. This design allows for some very powerful "one-liners" that would not be possible using the "intuitive" design described above (see some examples).

### Installation

find is part of the findutils package, which is part of the base package group. That is, it is included by default in Arch.

### Options

find has around 100 distinct options. However, they can be grouped into the following three categories.

#### Filesystem transversal

These include the following,

- whether or not to follow symbolic-links
- Optimizations to perform during transversal
- Whether or not produce a certain kind of diagnostic output

#### Expressions

Expressions are the meat and potatoes of find. They allow to filter the filesystem for a, potentially explicit, list files. In mathematical terminology, they allow you to define a relation on a list of files. This is the fundamental distinction between find and other search tools!

Expressions can be devided into the following categories

##### Tests

- file name
- depth of file under the directory
- file type
- modification date
- permissions of file
- shell command that takes the file as argument

##### Actions

- delete the file
- execute some shell command on the file

#### Operators

Operators allow you to combine sets of expressions together.

This article or section needs language, wiki syntax or style improvements.

Reason: Incomplete (Discuss in Talk:File system search#)

These include the basic logical operators such as AND, OR, NOT, as well as more complex combinors such as,

The power of find is the combination of this rich set of expressions.

### Usage

Any usage of find takes the following general form:

    $ find [filesystem transversal options] [list of directories to search] [list of expressions to perform]

For every file listed under the given directories, each expression is performed, from left to right. Thus, the order in which expressions are listed is important!

For example, the following commands give different results

This article or section needs language, wiki syntax or style improvements.

Reason: These commands will hardly give different results, what was the initial intention? (Discuss in Talk:File system search#)

       find
       find

## locate

`locate` is a common Unix tool for quickly finding files by name. It offers speed improvements over the find tool by searching a pre-constructed database file, rather than the filesystem directly. The downside of this approach is that changes made since the construction of the database file cannot be detected by `locate`. This problem is minimised by regular, typically scheduled use of the `updatedb` command, which (as the name suggests) updates the database.

### Installation

Although in other distros `locate` and `updatedb` are in the findutils package, they are no longer present in Arch's package. To use it, install the mlocate package. mlocate is a newer implementation of the tool, but is used in exactly the same way.

Before `locate` can be used, the database will need to be created. To do this, simply run `updatedb` as root.

### Keeping the database up-to-date

When `mlocate` is installed, a script is automatically scheduled to run daily via `systemd`, to update the database. You can also manually run `updatedb` as root at any time.

To save time, the `updatedb` can be (and by default is) configured to ignore certain filesystems and paths by editing `/etc/updatedb.conf`. `man updatedb.conf` will tell you about the semantics of this file. It is worth noting that among the paths ignored in the default configuration (i.e. those in the "PRUNEPATHS" string) are `/media` and `/mnt`, so `locate` may not discover files on external devices.

## Desktop search engines

This article or section is a candidate for merging with List_of_applications/Utilities#Desktop_search_engines.

Notes: This list was originally there. (Discuss in Talk:File system search#Move to upstream)

See also Wikipedia:List of search engines#Desktop search engines.

- Baloo — KDE's file indexing and search solution

  https://community.kde.org/Baloo || baloo

- Catfish — Versatile file searching tool

  https://launchpad.net/catfish-search || catfish

- Docfetcher — A java open source desktop search application

  http://docfetcher.sourceforge.net || docfetcherAUR

- Gnome Search Tool — Default Gnome utility to search for files

  http://gnome.org || gnome-search-tool

- Gnome Search Tool No Nautilus — gnome-search-tool to search for files without GNOME Files or gnome-desktop

  || gnome-search-tool-no-nautilusAUR

- Pinot — Personal search and metasearch tool

  http://code.google.com/p/pinot-search/ || pinot

- Recoll — Full text search tool based on Xapian backend

  http://www.lesbonscomptes.com/recoll/ || recoll

- Searchmonkey — A powerful GUI search utility for matching regex patterns

  http://searchmonkey.sourceforge.net/ || searchmonkeyAUR

- Strigi — Fast crawling desktop search engine with a Qt GUI.

  http://strigi.sourceforge.net/ || strigi

- Tracker — All-in-one indexer, search tool and metadata database.

  http://projects.gnome.org/tracker/index.html || tracker

## See also

- Official GNU find documentation
- How locate works and rewrite it in one minute

Category:

- Search