Files located in /var
are very much system-critical. For example, /var/mail
or /var/spool/mail
contains the users' email; you would no more delete that than you would light a fire in your neighbor's mailbox. It's only files in certain subdirectories of /var
that contain files that are more or less transitory: log files in /var/log
, caches that can usually be recreated in /var/cache
, temporary files (which you should not delete while they're in use!) in /var/tmp
.
Data in /var/lib
can be quite critical. For example, MySQL is usually configured to store its databases in /var/lib/mysql
by default: if you erase that, you wipe your databases. Dpkg puts its own databases under /var/lib
as well; /var/lib/dpkg/status
is one.
/var/lib/dpkg/status
contains information about installed packages. If you've erased that, you should restore it from a backup. If your backup isn't fully up-to-date, check the logs of recent package manipulations under /var/log/apt
and in /var/log/dpkg.log
. You'll need to create that file before dpkg
will work.
/var/lib/dpkg/available
is built from data downloaded from the Internet. apt-get update
should rebuild it.
/var/lib/dpkg/info
contains files that ship with Debian packages. You can restore these files simply by reinstalling the packages. Of course, you will need a list of installed packages for that. If you've restored /var/lib/dpkg/status
, then you can extract the list of packages from there.
apt-get install --reinstall $(</var/lib/dpkg/status sed -n 's/^Package://p')
If you've lost /var/lib/dpkg/status
, then you may be able to recreate it by creating an empty file, then running apt-get install --reinstall
on the list of packages. One place where the list of packages is also saved is /var/lib/apt/extended_states
, at least if you've only ever used APT to install packages (as opposed to dpkg
directly) — use that file instead of /var/lib/dpkg/status
int the command above. If you've deleted that too, you can rebuild an approximate list of packages with $(cd /usr/share/doc && ls)
, because most packages create an entry in /usr/share/doc
. There are probably a few exceptions.
Do not ask for any assistance about package management on this system. Recovering from the deletion of system-critical files is not an exact science. If you can't restore from backups, you should install a new, clean system as soon as possible.
/var/lib/dpkg/info
is quite important, too. You have misunderstood the FHS, and AFAIK the only recovery paths are (a) restore from backup or (b) reinstall. – derobert Oct 13 '14 at 17:56