Reinstalling deleted directories.

James Wilkinson ubuntu at westexe.demon.co.uk
Wed Apr 27 12:37:20 UTC 2005


Frank Hahn wrote:
> I believe I have deleted some directories and other
> files by mistake.  Is there a way in Ubuntu (Hoary
> 5.04) to reinstall these directories/files without
> reinstalling the whole system?
> 
> I see that within the apt-get command, there is the
> option to do something like this:
> 
> apt-get --reinstall install pkgname

That sounds about right.

> Is there a command that will check all the packages
> that have been installed from both the install CD and
> the installed packages.

Well, you can apt-get install debsums, which will list all the files
from a package and whether they're OK or not. That only works if the
sums for the package are available: not all packages have md5sums.

(Note that it isn't prelink-aware: *if* you've installed and run
prelink, then the signatures of executables will have changed).

To get what you want, you're going to have to do some shell scripting.
The command
dpkg-query -W --showformat='${Package}\n'
will get a list of each package that's installed.
This command:
for i in $(dpkg-query -W --showformat='${Package}\n') ; do debsums $i ; done
will get you a *long* list of each file on the machine (that's been
installed through .deb packages), and its status.

You probably want to ignore a lot of the output lines: try something
like:
for i in $(dpkg-query -W --showformat='${Package}\n') ; do debsums $i ; done | grep -v ' OK$' 

Then the command
dpkg-query -S $FILENAME
will show you which package owns $FILENAME.

I must admit to not being too familiar with dpkg: I've been working on
RPM based distros. So there may be an easier way of doing some of this.
The RPM equivalent is the command
rpm -Va
which seems a lot simpler to me...

James.

-- 
E-mail address: james | ... boxing the books up was a mistake: they are
@westexe.demon.co.uk  | welded to the floor through the power of gravity.
                      |     -- Telsa Gwynne's Diary.




More information about the ubuntu-users mailing list