How to delete the/var/lib/dpkg/info folder of dpkg by mistake

Source: Internet
Author: User
Delete the/var/lib/dpkg/info folder of dpkg by mistake. when installing the software today, the following error occurs: E: Sub-process/usr/bin/dpkgreturnedanerrorcode (1) the online query solution was misled by the Internet. I accidentally deleted the dpkg info... the following error occurs when the/var/lib/dpkg/info folder of dpkg is accidentally deleted: sub-process/usr/bin/dpkg returned an error code (1) Online Query solution, misled by the Internet, accidentally deleted the dpkg info folder, when you run the apt-get or dpkg command, the system always prompts "dpkg: Warning: the file name list file of the package ****** cannot be found, now, it is assumed that no file is installed in the software package in the system. "I checked it online and saved the configuration file list of each software in the info folder, which is really careless. After trying a lot of online legends, the methods are not easy to use, so I had to sacrifice Google artifacts and finally found a solution in a foreign article to execute the following script #! /Bin/bashset-e # Clean out/var/cache/apt/archivesapt-get clean # Fill it with all. debs we needapt-get -- reinstall-dy install $ (dpkg -- get-selections | grep '[[: space:] install' | cut-f1) DIR = $ (mktemp-d-t info-XXXXXX) for deb in/var/cache/apt/archives /*. debdo # Move to working directory cd "" DIR "# Create DEBIAN directory mkdir-p DEBIAN # Extract control files dpkg-deb-e" $ deb "# Extract File list, fixing up the leading. /and turning//. dpkg-deb-c "$ deb" | awk '{print $ NF}' | cut-c2-| sed-e's/^ \/$ /\/. /'> DEBIAN/list # Figure out binary package name DEB =$ (basename "$ deb" | cut-d _-f1) # Copy each control file into place cd DEBIAN for file in * do cp-a "$ file"/var/lib/dpkg/info/"$ DEB ". "$ file" done # Clean up cd .. rm-rf DEBIANdonermdir "$ DIR" is used to download all installed software packages and Copy the extracted file list information to the info folder. After the execution is complete prompt x11-common empty file list, unknown reason, can only execute replacement method, copy the x11-common file from another ubuntu, but still prompt dpkg warning, such as chrome, the software had to be manually installed, and the problem was solved after chrome and WPS were manually re-installed. apt-get and dpkg finally had no warning. Although the problem is solved, I don't know whether to solve it completely. For the moment, I just need to reinstall it if there is a problem. wow ~
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.