From b6280a8581288f637104c35d52225eaa32765e5c Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Wed, 12 Feb 2025 15:36:40 +0100 Subject: [PATCH] separate system search --- basics/locating.md | 55 ++++++++++--------------------------------- data/search_system.md | 49 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 42 deletions(-) create mode 100644 data/search_system.md diff --git a/basics/locating.md b/basics/locating.md index f710007..ddfec47 100644 --- a/basics/locating.md +++ b/basics/locating.md @@ -6,57 +6,28 @@ tags: [ "Basics" ] `type` shows what kind of thing you're running, be it an alias, function, or binary program. -```bash -type cmus +```sh +type cd +type ls +type -P ls +type -a cat ``` # Whereis the Program -Ask where the `angband` program is, along with all its configuration files: +Where is `grep` and all its configuration files? -`whereis angband` - -Also `which` shows where a binary file (the program) is, - -```bash -which cmus +```sh +whereis grep ``` -# Search Instantly with `plocate` +Which one of these is the binary file which you actually use? -You can search every file on the computer instantly by installing `plocate`. - -Once installed, run `sudo updatedb` to create the database of (nearly) every file on the computer. - -Check how big the database is: - -```bash -du -h /var/lib/plocate/plocate.db +```sh +which grep ``` -Once you have the database, you can find nearly any file instantly. +# More -- Search for gifs: `locate .gif` -- Search for gifs in the `/usr/` directory: `locate /usr/ .gif` -- Search for jpg images with 'dog' or 'Dog' in the name: `locate -i dog jpg` -- Search for videos: `plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$'` - -For best results, run `updatedb` regularly, perhaps in [crontab](../system/cron.md). - -## Search More Places - -`plocate` will not search `/tmp/`, because nobody cares about those files, and won't search inside `/mnt/`, because that's where USB sticks get mounted, so the files keep changing as USB sticks come and go. - -Change where `plocate` searches by editing the configuration file at `/etc/updatedb.conf`. - -By default, the `/mnt` directory is 'pruned' from the database. -So if you want to search `/mnt` for videos, remove the word `/mnt` from the configuration file. - - -```bash -cat /etc/updatedb.conf -sudo sed 's#/mnt/##' /etc/updatedb.conf -sudo updatedb -plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$' -``` +- [Search instantly with `plocate`](data/search_system.md) diff --git a/data/search_system.md b/data/search_system.md new file mode 100644 index 0000000..1d5f1a8 --- /dev/null +++ b/data/search_system.md @@ -0,0 +1,49 @@ +--- +title: "Search System" +tags: [ "data", "search", "locate", "plocate" ] +requires: "cron" +--- + +You can search every file on the computer instantly by installing `plocate`. + +Once installed, run `sudo updatedb` to create the database of (nearly) every file on the computer. + +Check how big the database is: + +```sh +du -h /var/lib/plocate/plocate.db +``` + +Once you have the database, you can find nearly any file instantly. + +- Search for gifs: `locate .gif` +- Search for gifs in the `/usr/` directory: `locate /usr/ .gif` +- Search for jpg images with 'dog' or 'Dog' in the name: `locate -i dog jpg` +- Search for videos: `plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$'` + +For best results, run `updatedb` regularly, perhaps in [crontab](../system/cron.md). + +## Search More Places + +`plocate` will not search `/tmp/`, because nobody cares about those files, and won't search inside `/mnt/`, because that's where USB sticks get mounted, so the files keep changing as USB sticks come and go. + +Change where `plocate` searches by editing the configuration file at `/etc/updatedb.conf`. + +By default, the `/mnt` directory is 'pruned' from the database. +So if you want to search `/mnt` for videos, remove the word `/mnt` from the configuration file. + + +```bash +su root +cat /etc/updatedb.conf +sed -i 's#/mnt/##' /etc/updatedb.conf +updatedb +exit +``` + +Now you can search in `/mnt` for films: + +```sh +plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$' +``` +