brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: plocate finds a file by name in milliseconds, from an index

Find
~/tips/tip-find-plocate-index-search

sudo apt install plocate

Looks up files by name in a prebuilt index instead of walking the whole disk.

find walks the disk every time you ask it something. That is what you want for fresh results, but for a plain where-on-this-machine-is-that-file question it is a slow way to get an answer, especially on a server with a few million files.

plocate answers from a database instead. On Debian and Ubuntu the package is simply called plocate:

sudo apt install plocate
sudo updatedb
plocate -i -b nginx.conf

updatedb builds the index, and after that a systemd timer usually refreshes it once a day. -i ignores case and -b only matches the file name, so a folder called nginx.conf.d somewhere in a path does not flood your screen. Give it more than one pattern and plocate only shows paths that match all of them, which is a nice way to narrow things down:

plocate docker-compose.yml immich

-c prints a count instead of the list and -l 20 stops after twenty matches.

The caveat is the index itself. It is only as fresh as the last updatedb run, so a file you made ten minutes ago will not show up yet, and a file you deleted may still be listed (-e hides entries that no longer exist). plocate also respects permissions: it only shows files your own user could reach with find, so without sudo you will miss folders you have no access to. For anything that has to be current right now, I would still reach for find.

Further reading: plocate(1) manual page, updatedb(8) for plocate

Going deeper: Run degoog on Unraid as your own search page, compared with SearXNG and 4get

More Find tips find / -maxdepth 1 -fstype proc find /backup -name '*.gz' ! -exec gzip -t {} \; -print 2>/dev/null find /srv/downloads -type f -size +100M -size -1G -exec ls -lh {} + find /srv/data -depth -print find /srv -xdev -samefile /srv/downloads/movie.mkv All Find tips (46) All topics

Link