Commands:files:installing
From Linux How-To Repository
Finding Missing Files
If you delete a single file or directory and want to know what package provided it, the APT tools can quickly come to your rescue again. The dpkg –S option identifies the package that provided a specific file, as in the following example:
dpkg –S /bin/ls
coreutils: /bin/ls
You can also use the apt-file command to identify the package that contains the missing file.
To know what package to install to get the missing file or application, use apt-file. It's not a part of a standard Ubuntu installation, but you can quickly install it.
apt-get install apt-file
Once apt-file is installed, download the files that describe packages and their contents, using:
sudo apt-file update
Once the update completes, you can locate the missing file or utility using the apt-file search option, as in the following example:
apt-file search /usr/bin/jove
jove: usr/bin/jove
Finding Relevant Packages
One way to identify packages whose names match a specific substring is dpkg.
dpkg –l ’*emacs*’
A better way is to use apt-cache search:
apt-cache search emacs
Verifying the Integrity of Installed Packages
What do you do when files disappear? Short of reinstalling everything, use the debsums command to generate and verify the MD5 checksums of files that have been installed from Debian packages.
Install debsums using your favorite package management tool, change directory to /var/cache/apt/archives (where the APT tools store downloaded packages), and do the following:
sudo apt–get ––download–only ––reinstall install `debsums –l`
This command retrieves all of the packages that are installed on your system, but which don’t have an MD5 checksums file. Now generate the checksums for all installed packages whose debs are present on your system but which don’t already have MD5 checksums, and keep them in files in the working directory:
sudo debsums --generate=nocheck *.deb
Next, use debsums to display error information for files and directories that differ from the values in the original packages:
debsums –s
You can then use the resulting list of missing files and associated packages to work out what you have to reinstall. (The debsums script is also useful for verifying the integrity of your system if you’ve been hacked.)
