How to search for a file in apk packages
18,382
Solution 1
You have three ways basically.
First: The package should be installed and you need to specify the full path :
apk info --who-owns /path/to/the/file
Second: Use the pkgs.alpinelinux.org website
Third: Use the api.alpinelinux.org API by filtering the json output. For this you need a json parser like jq:
apk add jq
then use the API with the instructions provided here
UPDATE on 2022-04-07
I've released a tiny utility that allows to search via CLI what can be found on pkgs.alpinelinux.org website: https://github.com/fcolista/apkfile
.: Francesco
Solution 2
You're looking for the equivalent of Debian's apt-file
for Alpine. Searching for that yields apk-file.
Basically apt-file but for alpine.
Solution 3
- Go to the official Alpine package-browsing website: https://pkgs.alpinelinux.org/contents
- In the
File
search bar, type the name of the file you are looking for
Example looking for file telnet
:
Related videos on Youtube
![mike](https://i.stack.imgur.com/u5kfT.jpg?s=256&g=1)
Author by
mike
Updated on September 18, 2022Comments
-
mike almost 2 years
I would like to know, given a binary's name, which package I should install on Alpine Linux.
How can I do that?
-
Att Righ over 7 years
apk info
seems to be closer todpkg -S
. In my case I'm trying to answer the question "What package provides this binary that I know the name of", rather than where does this pre-existing file come from. -
Att Righ over 7 yearsThat's what I'm after. It appears that apk-file is not an alpine package, you can install it with
go get github.com/jessfraz/apk-file
(it happily runs on non alpine systems). The binary is likely static so can probably be copied into docker containers etc. -
Francesco Colista over 7 yearstherefore,
apk info --who-owns /with/th/full/path
is the tool if you have the package installed, otherwise from a CLI is not possible. You should check [pkgs.alpinelinux.org/contents] (pkgs.alpinelinux.org/contents) website. You write the binary name there, and it returns the package that contains that binary. -
Francesco Colista almost 7 yearsapt-file basically parses pkgs.alpinelinux.org website...so using a JSON decode as i wrote before would be better, since does not need bloated software to reach the same goal.
-
Elouan Keryell-Even about 6 yearsUsing
apk info --who-owns
, how do you do if you don't know the file's full path? -
Francesco Colista about 6 yearsNo, you can't as yet...sorry
-
Rolf about 4 yearswhy is --who-owns undocumented?
-
Francesco Colista about 4 yearsIt's documented. Read better the output of "apk info --help"
-
x-yuri about 4 yearsIndeed, you can see that with
-d
option. And it doesn't strip whitespaces. And for some reason with--arch
it doesn't display all the results.