apt remove 与 purge

apt remove 与 purge

我看到了sudo apt remove package_namesudo apt purge package_name
但是有什么区别呢?一个比另一个更安全吗?还是一个会删除由该包安装的包?

答案1

你可以使用以下命令阅读 apt 手册

man apt

第 35 行你会发现以下内容

       Removing a package removes all packaged data, but leaves usually
       small (modified) user configuration files behind, in case the
       remove was an accident. Just issuing an installation request for
       the accidentally removed package will restore its function as
       before in that case. On the other hand you can get rid of these
       leftovers by calling purge even on already removed packages. Note
       that this does not affect any data or configuration stored in your
       home directory.

简而言之: remove在没有配置文件的地方留下一些配置文件purge。如果以后您想删除这些配置文件,您甚至可以使用清除功能。

答案2

apt-get(运行man 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).

简而言之,remove保留配置文件,purge删除配置文件。两者都是安全的,但选择哪一个取决于您是否要删除配置。

相关内容