誤刪dpkg的/var/lib/dpkg/info檔案夾的解決辦法

來源:互聯網
上載者:User

誤刪dpkg的/var/lib/dpkg/info檔案夾的解決辦法 今天安裝軟體時時,出現這樣的錯誤提示:E: Sub-process /usr/bin/dpkg returned an error code (1) 上網查解決方案,被網上誤導,一不小心誤刪了dpkg的info檔案夾,之後在使用apt-get 或者 dpkg命令總是提示 “dpkg:警告:無法找到軟體包 ******* 的檔案名稱列表檔案,現假定該軟體包目前沒有任何檔案被安裝在系統裡” 上網查了一下,info檔案夾儲存各個軟體的設定檔列表,真是粗心大意啊。 試了很多網上傳說的方法都不好用,只好祭出Google神器,終於在國外的一個文章中找到瞭解決方案 執行下面的指令碼 #!/bin/bashset -e # Clean out /var/cache/apt/archivesapt-get clean# Fill it with all the .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 / into /.    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" 原理是重新下載所有安裝過的軟體包,然後從中提取檔案清單資訊複製到info檔案夾裡。 執行完畢後提示x11-common有空檔案清單,原因不明,只能執行替換法了,從別的ubuntu上拷貝了x11-common的檔案, 但是依然提示dpkg警告,例如chrome的,對於這些軟體只好手動安裝了,手動重新安裝chrome和WPS之後問題解決 apt-get和dpkg終於沒有警告了。雖然問題解決,也不知道是否解決徹底,暫時就這樣吧,如果在有問題只好重裝了,哇哢哢~ 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.