What package does this file belong to?
2015-01-26 19:26
It is often useful to find out what package a file belongs to. Unfortunately this is dependent on package manager and if you run different systems with different package managers it can be tricky to remember how you find this information for a perticular package manager. So, here's some notes about how to find this information for some package managers.
apt-get
You need apt-file to be able to find out what package a file belongs to:
$ sudo apt-get install apt-file
You also need to get a cache for apt-file to use:
$ sudo apt-file update
Now you can find out. For example, what package does the command aplay belong to?
$ apt-file search /bin/ls
This should reply with a list of all packages containing the pattern /bin/ls
. Use grep to narrow it down if the list is to long.
See man apt-file for detailed information.
dpkg
To continue using aplay as example:
$ dpkg -S /bin/ls
This should return:
coreutils: /bin/ls
rpm
$ rpm -qf $(which ls)
Should return something like
coreutils-8.12-2.fc16.x86_64
portage (emerge)
gentoolkit contains the equery tool, so install that first:
$ sudo emerge gentoolkit
Then use the b
flag to find out what package a file belongs to:
$ equery b /bin/ls
The result looks something like:
* Searching for /bin/ls ...
sys-apps/coreutils-8.21 (/bin/ls)
FreeBSD Ports
FreeBSD 10 and newer:
$ pkg which /usr/local/bin/vim
Looking for /bin/ls
does reply that it was not found in database so I'm guessing base system tools are not registered.
Prior to FreeBSD 10 the command pkg_info was used:
$ pkg_info -W /bin/ls
Not sure if the same thing applies here, that base system tools isn't registered. I have no system to verify on.