lk/basics/locating.md

63 lines
1.7 KiB
Markdown
Raw Normal View History

2022-01-16 18:20:39 +00:00
---
title: "locating"
2022-01-26 21:29:48 +00:00
tags: [ "Documentation", "Basics" ]
2022-01-16 18:20:39 +00:00
---
2022-01-26 21:29:48 +00:00
# Type
`type` shows what kind of thing you're running, be it an alias, function, or binary program.
```bash
type cmus
```
2022-01-26 21:29:48 +00:00
2020-01-05 12:33:53 +00:00
# Whereis the Program
2020-01-02 00:04:35 +00:00
2020-01-05 12:33:53 +00:00
Ask where the `angband` program is, along with all its configuration files:
2020-01-02 00:04:35 +00:00
`whereis angband`
2020-01-02 18:20:55 +00:00
Also `which` shows where a binary file (the program) is,
```bash
which cmus
```
2020-01-02 18:20:55 +00:00
2025-01-14 04:05:36 +00:00
# Search Instantly with `plocate`
2020-01-02 00:04:35 +00:00
2025-01-14 04:05:36 +00:00
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:
2020-01-05 12:33:53 +00:00
```bash
2025-01-14 04:05:36 +00:00
du -h /var/lib/plocate/plocate.db
```
2020-01-05 12:33:53 +00:00
2025-01-14 04:05:36 +00:00
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.
2020-01-05 12:33:53 +00:00
```bash
2025-01-14 04:05:36 +00:00
cat /etc/updatedb.conf
sudo sed 's#/mnt/##' /etc/updatedb.conf
sudo updatedb
plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$'
```
2020-01-02 00:04:35 +00:00