Finding which package contains a file
Posted by Steve on Wed 18 Jan 2006 at 16:53
There are times when you're looking for a particular library, or file, which you know is available to Debian but you cannot find the package which contains it. This is the kind of job that the Debian packages site helped with in the past, but given its current unavailability we'll look at another approach.
Finding the package which has installed a particular file upon your system is accomplished via the dpkg command. This can be used as follows:
steve@skx2:~$ dpkg --search /etc/bash_completion bash: /etc/bash_completion
Here we've used the --search argument to discover which locally installed package placed the file /etc/bash_completion upon the system - and it showed us that the file belongs to the bash package.
But what if you know you need to find a particular file to finish a compilation? And you don't know which package it is contained in?
The solution to this related problem is to use the apt-file command. This will allow you to search the files which are contained in packages.
Install it with:
apt-get install apt-file
Once installed you'll need to download the actual data which it uses to search. This can be accomplished with the following command:
apt-file update
Once you've downloaded data you can now proceed to searching for packages.
Recently I wanted to compile some software and I didn't know which package contained the header I neede to use (alisp.h). Using apt-file i it was simple to find out:
skx@itchy:~$ apt-file search alisp.h libasound2-dev: usr/include/alsa/alisp.h
That showed me that the package libasound2-dev contains the file alisp.h. Once I'd installed the package I was able to compile the code I'd downloaded.
[ Parent | Reply to this comment ]
Another useful command is dpkg -L <package>, which shows all the files installed by a given package.
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
For some reason I always forget about "dpkg -L" and end up reading /var/lib/dpkg/info/packageName.list!
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
Hi
another nice command is auto-apt. For searching files, it's the same thing:
auto-apt update auto-apt search test.hbut it can do even more. If you run it with
auto-apt run ./configurein your standard not-yet-released-in-debian package, then auto-apt will prompt you on every file it knows could be on your computer, if only you'd have that package installed...
Unfortunatly, it doesn't take
deb file://sources from sources.list.
Ineiti
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Using apt-listchanges will show you the changelog of packages you're upgrading.
Failing that you can see the changelogs of packages you have installed in /usr/share/packageName/.
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
apt-listchanges is a great. i use it to keep myself up-to-date about what's happening in debian, particularly on a relatively well-used testing/unstable system.
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Of course you are correct. I must have typed that too quickly to make such a silly mistake!
[ Parent | Reply to this comment ]
james@moleman:~$ wajig JIG> help Common JIG commands: update Update the list of down-loadable packages new List packages that became available since last update newupgrades List packages newly available for upgrading install Install (or upgrade) one or more packages or .deb files remove Remove one or more packages (see also purge) toupgrade List packages with newer versions available for upgrading upgrade Upgrade all of the installed packages or just those listed listfiles List the files that are supplied by the named package listnames List all known packages or those containing supplied string whatis For each package named obtain a one line description whichpkg Find the package that supplies the given command or file Run LIST-COMMANDS for a complete list of commands. JIG> whichpkg alsamixer File Path Package ===========================================================-===== ============ /usr/bin/alsamixer alsa-utils /usr/share/doc/alsa-utils/README.alsamixer alsa-utils /usr/share/man/man1/alsamixer.1.gz alsa-utils JIG>
It is extremely powerful and you don't have to use the pseduo-shell it creates.
All the commands/options can be called from the command at the prompt.
[ Parent | Reply to this comment ]
dlocate -S /etc/bash_completion
or
dlocate -L bash
[ Parent | Reply to this comment ]
Error: cp: cannot stat `/cdrom/dists/unstable/Contents-i386.gz': No such file or directory
I use Debian Sarge DVD and in dists/unstable or dists/[sarge stble unstable] no any Content* file !!
[ Parent | Reply to this comment ]
--20:20:18-- http://security.debian.org//dists/stable/updates/Contents-i386.gz
=> `/var/cache/apt/security.debian.org_dists_stable_updates_Contents -i386.gz'
Resolving security.debian.org... 82.94.249.158, 128.101.80.133, 194.109.137.218
Connecting to security.debian.org[82.94.249.158]:80... connected.
HTTP request sent, awaiting response... 404 Not Found
20:20:18 ERROR 404: Not Found.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
You could see those (some) configuration files with:
#debsums -e <packagename>And the one you changed (maybe more interessting)
#debsums -ce <packagename>
In your example
#debsums -e sudo
does not list:
/etc/sudoers
And also Files like:
/etc/apache2/httpd.conf or
/etc/apache2/ports.conf
are not listed (unfortunately like most configuration files).
Like you wrote, those files are dynamically generated during installation.
I do not know of any system (except file integrity/alteration checker [like samhain, tripwire or maybe FAM.])
which could track this.
If anyone knows another solution, I would love to hear it.
btw. where did you read this?
"I read that this is because this file is created during the installation process"
Cheeers
[ Parent | Reply to this comment ]