error while loading shared libraries: libxshmfence.so.1: [duplicate]
Simple enough question: is there some shell command (or GUI method) I can use that, given the path to a file on my system, tells me what package put it there? Assuming the file did in fact come from a package, that is.
Bonus question: what if it's a file that isn't installed on my system? Is there, say, a website that will let me look up a file and see what packages, if any, provide it?
You can use dpkg
command to find out which installed package owns a file:
From man dpkg
:
-S, --search filename-search-pattern... Search for a filename from installed packages.
Example:
$ dpkg -S /bin/ls
coreutils: /bin/ls
You can either search with a full path or with just the filename.
If you wish to search for files not yet installed on your computer, you can use the Ubuntu Packages Search, or apt-file
as described in a different answer.
The apt-file
command can do this for you from the command line. I use it frequently when building packages from source. For files provided by packages that are already installed on your system, apt-cache
is another choice.
To install apt-file
, do:
sudo apt-get install apt-file
Then, you need to update it's database:
sudo apt-file update
And, finally, search the file:
$ apt-file find kwallet.h
kdelibs5-dev: /usr/include/kwallet.h
libkf5wallet-dev: /usr/include/KF5/KWallet/kwallet.h
However a much friendlier way is to use the Ubuntu Packages Search website. They have an option to "search the contents of packages" for a specific filename.
There's also apt-file for looking up files in packages that aren't installed. For example:
apt-file list packagename
You can search the contents of packages included in the various Ubuntu releases on the Ubuntu Packages website. Look under the heading "Search the contents of packages".
For example, here are the search results for libnss3.so in focal (20.04):
http://packages.ubuntu.com/search?searchon=contents&keywords=libnss3.so&mode=exactfilename&suite=focal&arch=any
You mean, which package and not which application. The application is your package manager, e.g. Software Center
.
Using dpkg
:
dpkg -S /usr/lib/tracker/tracker-store
dpkg -S tracker-extract
dpkg -S tracker-miner-fs
Example
% dpkg -S /usr/lib/tracker/tracker-store
tracker: /usr/lib/tracker/tracker-store
Using apt-file
:
apt-file search /usr/lib/tracker/tracker-store
or also possible:
apt-file search --regex /tracker-extract$
apt-file search --regex /tracker-miner-fs$
Example
% apt-file search /usr/lib/tracker/tracker-store
tracker: /usr/lib/tracker/tracker-store
Or online here, in the section Search the contents of packages
.
Example