Locating the right file or folder quickly in Linux matters when configuration paths, logs, backups, or application data are spread across a large filesystem. Fast, precise searches reduce guesswork before editing files, rotating data, or checking whether a directory exists in the expected location.

The find command walks the live filesystem from a starting path and tests each entry against conditions such as name, type, depth, size, and modification time. The locate command answers the same kind of question from a prebuilt path index, so it is much faster for broad lookups but only as current as its last updatedb run.

Search scope affects both speed and signal. Running find from a focused starting directory is usually faster and clearer than searching from /, while system-wide searches may need sudo and can still return permission errors unless they are redirected. Indexed lookups also vary by distribution: many current systems provide locate through plocate or an mlocate-compatible package, and minimal installs may not include it until added.

Steps to find files and folders in Linux:

  1. Search for a file by its exact name from the most relevant parent directory.
    $ find /srv/search-demo -type f -name "report-2024.txt"
    /srv/search-demo/reports/report-2024.txt

    -type f limits matches to regular files so directories with the same name are excluded.

  2. Search for a folder by name by switching the type filter to directories.
    $ find /srv/search-demo -type d -name "reports"
    /srv/search-demo/reports

    -type d returns directories only, which is useful when the target is a project tree, upload directory, or application data path.

  3. Match filename patterns and keep the search near the current subtree by combining -name with -maxdepth.
    $ find /srv/search-demo -maxdepth 2 -type f -name "*.txt" | sort
    /srv/search-demo/.hidden.txt
    /srv/search-demo/reports/report-2023.txt
    /srv/search-demo/reports/report-2024.txt

    Quote glob patterns such as "*.txt" so the shell does not expand them before find runs.

  4. Ignore case when the exact capitalization is unknown.
    $ find /srv/search-demo -type f -iname "settings.conf"
    /srv/search-demo/Archive/Settings.conf

    The -iname test is useful on mixed-case directory trees where the file name is remembered but not its exact spelling.

  5. Narrow the result set by modification time when several files share similar names.
    $ find /srv/search-demo/reports -type f -mtime -2 | sort
    /srv/search-demo/reports/report-2023.txt
    /srv/search-demo/reports/report-2024.txt

    -mtime -2 matches files modified within the last two 24-hour periods. Use +N for files older than N days.

  6. Filter by size when the goal is to locate large files or sparse data dumps.
    $ find /srv/search-demo -type f -size +1M
    /srv/search-demo/large.bin

    Size tests accept units such as k, M, and G. Prefix the value with + for larger than or - for smaller than the threshold.

  7. Search the local filesystem root when the path is unknown and avoid crossing into other mounted filesystems.
    $ sudo find / -xdev -type f -name "shadow" 2>/dev/null
    /etc/shadow

    -xdev keeps the search on the current filesystem, which prevents results from expanding into mounted backup, container, or network volumes. Redirecting stderr hides permission noise, so use it only when the search scope is already clear.

  8. Refresh the indexed path database before relying on locate for recent filesystem changes.
    $ sudo updatedb

    On many current distributions, updatedb is provided by plocate and usually runs from a scheduled timer. Minimal installations may not include locate until the package is added.

  9. Use locate for a fast name lookup when the database is available.
    $ locate report-2024.txt
    /srv/search-demo/reports/report-2024.txt

    locate searches the last built database, so renamed or newly created paths can be missing until the index is refreshed.

  10. Confirm the returned path before editing, moving, or deleting the result.
    $ ls -ld /srv/search-demo/reports/report-2024.txt
    -rw-r--r-- 1 root root 5 Apr 14 10:15 /srv/search-demo/reports/report-2024.txt

    Listing the match confirms the file type, permissions, timestamp, and final path before a follow-up action such as opening the file or removing it.