Command to Find a Command's Apt Package
Sometimes I type a command in linux and it's not found. I try to install it and it's not found.
> foo
(not found)
> apt install -y foo
(no install candidate)
Often it will say what package you need to install, but when it doesn't it's usually something like "archery-tools2" or something you'd never guess and if you did you'd wished you'd gone to Vegas instead. You'd have to be pretty lucky.
Googling said I could do: dpkg -S /usr/bin/top
which is cool but that means it is already installed and so... moot.
# (For the record, ^^^ command to find out where a specific command comes from:)
> root@5e60afe003a9:/# dpkg -S /usr/bin/top
coreutils: /usr/bin/top
But, apt-file
to the rescue!
Oh, but you have to install it. Sigh. At least it's the same name as the package.
> apt update -y && apt install -y apt-file && apt-file update
Okay, now you can search. Easy as pi. Say you want to install 'top':
> apt-file search top
Er...
eg: apt-file search top
apt-file search /usr/bin/top
apt-file search "/usr/bin/top"
apt-file search "top$"
apt-file search -E "top$"
apt-file search --regex "top$"
apt-file search --regex "\btop$"
apt-file search --regex "\/top$" # <<< wow, you REALLY gotta want it!!