apt-get remove -y 和 apt-get purge -y 之間的區別?

apt-get remove -y 和 apt-get purge -y 之間的區別?
apt-get remove <name of program>  

apt-get purge <name of program>

apt-get purge -y <name of program>

研究表明,執行「刪除」或「清除」執行完全相同的功能,並且它們是可互換的命令。

運行該命令apt-get purge -y <name of program>將刪除該程式及其相依性。

IOW,此命令是否刪除與該程式嚴格關聯的依賴項,或者是否有可能刪除可能導致其他程式停止工作的共用依賴項?

我應該運行哪個來刪除程式?purge或者purge -y

答案1

apt-get remove刪除有問題的包

apt-get purge相當於apt-get remove --purge並將刪除用戶資料/設定檔。

man apt-get

   purge
       purge is identical to remove except that packages are removed and purged (any configuration files are deleted too).

   --purge
       Use purge instead of remove for anything that would be removed. An asterisk ("*") will be displayed next to packages which are scheduled to be purged.  remove --purge is equivalent to the purge command. Configuration Item: APT::Get::Purge.

-y標誌告訴指揮部無需確認瑣碎問題即可繼續進行。再次,來自man apt-get

   -y, --yes, --assume-yes
       Automatic yes to prompts; assume "yes" as answer to all prompts and run non-interactively. If an undesirable situation, such as changing a held package, trying to install a unauthenticated package or removing an essential package occurs then apt-get will abort. Configuration Item: APT::Get::Assume-Yes.

答案2

的手冊頁apt-get包含以下資訊 -

   remove
       remove is identical to install except that packages are removed
       instead of installed. Note that removing a package leaves its
       configuration files on the system. If a plus sign is appended to
       the package name (with no intervening space), the identified
       package will be installed instead of removed.

   purge
       purge is identical to remove except that packages are removed and
       purged (any configuration files are deleted too).

因此,如果您希望刪除特定套件的所有配置文件,purge這是更好的選擇。但是,如果您希望保留配置文件,remove則應使用。

   -y, --yes, --assume-yes
       Automatic yes to prompts; assume "yes" as answer to all prompts and
       run non-interactively. If an undesirable situation, such as
       changing a held package, trying to install a unauthenticated
       package or removing an essential package occurs then apt-get will
       abort. Configuration Item: APT::Get::Assume-Yes.

-y標誌不會刪除依賴項,而是跳過使用者確認刪除包的操作,假設 Y/N 提示中的「是」。

要刪除導致問題或不需要再次安裝的軟體包,最好的選擇是 -

apt-get purge <packagename>

這是因為,如果應用程式的設定檔被修改而導致錯誤,purge則會將其刪除,從而有效地使後續安裝顯示為全新安裝。

注意:此purge選項不適用於在使用者主資料夾中儲存設定檔的套件。參考這個答案了解更多詳情。

相關內容