apt-get卸载整理

apt-get卸载整理


我们平时在安装软件后,有时会有删除,重新安装的需求,但总是删除不干净。其实,就是我们对命令的不熟悉。

一、学会查命令的文档:

apt-get --help

执行结果:

apt 1.2.32ubuntu0.2 (amd64)

Usage: apt-get [options] command

       apt-get [options] install|remove pkg1 [pkg2 ...]

       apt-get [options] source pkg1 [pkg2 ...]



apt-get is a command line interface for retrieval of packages

and information about them from authenticated sources and

for installation, upgrade and removal of packages together

with their dependencies.



Most used commands:

  update - Retrieve new lists of packages

  upgrade - Perform an upgrade

  install - Install new packages (pkg is libc6 not libc6.deb)

  remove - Remove packages

  purge - Remove packages and config files

  autoremove - Remove automatically all unused packages

  dist-upgrade - Distribution upgrade, see apt-get(8)

  dselect-upgrade - Follow dselect selections

  build-dep - Configure build-dependencies for source packages

  clean - Erase downloaded archive files

  autoclean - Erase old downloaded archive files

  check - Verify that there are no broken dependencies

  source - Download source archives

  download - Download the binary package into the current directory

  changelog - Download and display the changelog for the given package



See apt-get(8) for more information about the available commands.

Configuration options and syntax is detailed in apt.conf(5).

Information about how to configure sources can be found in sources.list(5).

Package and version choices can be expressed via apt_preferences(5).

Security details are available in apt-secure(8).

                                        This APT has Super Cow Powers.

二、关于apt-get的卸载相关的命令有:remove / purge / autoremove / clean / autoclean

  • apt-get purge - Remove packages and config files
#删除已安装包(不保留配置文件)
apt-get purge
或
apt-get --purge remove

举个例子:软件包a,依赖软件包b,则执行该命令会删除a,而且不保留配置文件

  • apt-get autoremove - Remove automatically all unused packages

apt-get autoremove
#删除为了满足依赖而安装的,但现在不再需要的软件包(包括已安装包),保留配置文件。即:自动删除所有未使用的包

  • apt-get remove - Remove packages

apt-get remove
#删除已安装的软件包(保留配置文件),不会删除依赖软件包,且保留配置文件。

  • apt-get autoclean - Erase old downloaded archive files

apt-get autoclean
#APT的底层包是dpkg, 而dpkg 安装Package时, 会将 *.deb 放在 /var/cache/apt/archives/中,apt-get autoclean 只会删除 /var/cache/apt/archives/ 已经过期的deb。

  • apt-get clean - Erase downloaded archive files

apt-get clean
#使用 apt-get clean 会将 /var/cache/apt/archives/ 的 所有 deb 删掉,可以理解为 rm /var/cache/apt/archives/*.deb。

那么如何彻底卸载软件呢?具体来说可以运行如下命令:

apt-get --purge remove
#删除软件及其配置文件

apt-get autoremove
#删除没用的依赖包

dpkg -l |grep ^rc|awk ‘{print $2}’ |sudo xargs dpkg -P
#此时dpkg的列表中有“rc”状态的软件包,可以执行如下命令做最后清理:

当然如果要删除暂存的软件安装包,也可以再使用clean命令。

  • 4
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值