關於apt-get remove 與 apt-get purge

關於apt-get remove 與 apt-get purge
今天在Ubuntu服務器上安裝supervisor,部署沒成功想卸載重來,sudo apt-get remove supervisor 後發現配置文件還在,便手動刪除了配置文件。再次安裝,提示配置文件不存在,WTF!配置文件不該你軟件給我創建嗎?我想。

查閱資料才知,還有 apt-get purge 這一選項,purge 清除。

劃重點:
apt-get remove 會刪除軟件包而保留軟件的配置文件
apt-get purge 會同時清除軟件包和軟件的配置文件

但是爲什麼重新安裝會失敗呢?
系統中存在dpkg這麼一個工具,會記錄軟件包的狀態,不只是安裝和未安裝兩種狀態,會記錄以下這些狀態:

    not-installed - The package is not installed on this system
    config-files - Only the configuration files are deployed to this system
    half-installed - The installation of the package has been started, but not completed
    unpacked - The package is unpacked, but not configured
    half-configured - The package is unpacked and configuration has started but not completed
    triggers-awaited - The package awaits trigger processing by another package
    triggers-pending - The package has been triggered
    installed - The packaged is unpacked and configured OK

當執行apt-get install時,apt軟件包管理工具會先檢查要安裝的軟件的狀態,向我這種情況下,手動刪除了軟件配置後,並不會引起dpkg中記錄的狀態的改變,即仍爲 config-files 狀態,所以安裝過程會直接跳過創建配置文件這一過程。於是當軟件想要啓動進程的時候,才發現找不到文件。

所以當你想徹底地刪除軟件包的時候,用 apt-get purge 吧

原文:http://bencane.com/2014/08/18/removing-packages-and-configurations-with-apt-get/
————————————————
版權聲明:本文爲CSDN博主「奧林匹克競賽」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/digitalkee/article/details/104253791

發佈了161 篇原創文章 · 獲贊 100 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章