dpkg: error processing package xxxx (--configure): Errors were encountered while processing:xxx 解决方法

当我在 unbuntu 十分作死的用rm -rf删除了一些神奇的东西后(大概是关于tomcat的配置文件

然后在安装其他软件时就会出现这些错误

Setting up tomcat8 (8.0.32-1ubuntu1.6) ...
cat: /usr/share/tomcat8/defaults.template: No such file or directory
cat: /usr/share/tomcat8/logrotate.template: No such file or directory
chown: cannot access '/etc/tomcat8/policy.d': No such file or directory
dpkg: error processing package tomcat8 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 tomcat8
E: Sub-process /usr/bin/dpkg returned an error code (1)


折腾了半天之后,找到了解决办法


$ sudo mv /var/lib/dpkg/info/ /var/lib/dpkg/info_old/
$ sudo mkdir /var/lib/dpkg/info/
$ sudo apt-get update
...
$ sudo apt-get -f install
...
$ sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info_old/
$ sudo rm -rf /var/lib/dpkg/info
$ sudo mv /var/lib/dpkg/info_old/ /var/lib/dpkg/info/


输入上述命令之后,执行在  sudo apt-get update   和  sudo apt-get upgrade 就不会有问题了。

你可能感兴趣的:(dpkg: error processing package xxxx (--configure): Errors were encountered while processing:xxx 解决方法)