apt-get软件包管理器

升级所有软件包

sudo apt-get upgrade命令用于从/etc/apt/sources.list中列出的源安装系统上当前安装的所有软件包的最新版本。当前安装的任何软件包和可用的新软件包都将被检索和升级。首先运行sudo apt-get update命令很重要。

itr@ubuntu1510:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done

检查依赖项是否损坏

可以使用check参数来检查系统上是否有损坏的软件包。

itr@ubuntu1510:~$ sudo apt-get check
Reading package lists... Done
Building dependency tree       

使用apt-get管理软件包

apt-get是一个命令行驱动的实用程序,用于与APT(高级软件包工具)一起使用。apt-get仅适用于与dpkg不同的程序包名称,后者与.deb文件一起使用。apt-get是一种非常灵活,易于使用的工具,可维护其自己的软件包数据库。这使得升级软件包和处理依赖关系变得非常容易。apt-get主要用于基于Debian的系统,例如Ubuntu和Mint。

删除软件包

基本语法:sudo apt-get remove 软件包名称

itr@ubuntu1510:~$ sudo apt-get remove htop
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED
  htop
0 to upgrade, 0 to newly install, 1 to remove and 7 not to upgrade.
After this operation, 203 kB disk space will be freed.

发行版本升级

sudo apt-get dist-upgrade命令用于升级所有软件包,并管理来自较新版本软件包的依赖项。此命令将尝试以不重要的软​​件包为代价升级最重要的软件包。在此过程中,某些软件包可能会被删除。

itr@ubuntu1510:~$ sudo apt-get dist-upgrade
[sudo] password for itr: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed
  libandroid-properties1 linux-headers-4.2.0-27 linux-headers-4.2.0-27-generic
  linux-image-4.2.0-27-generic linux-image-extra-4.2.0-27-generic
The following packages will be upgraded:
  liboxideqt-qmlplugin liboxideqtcore0 liboxideqtquick0 linux-generic

清理磁盘空间

可以使用clean参数清除检索到的软件包文件的本地存储库。clean将从/var/cache/apt/archives/ 和 /var/cache/apt/archives/partial/中删除除锁定文件之外的所有内容。

itr@ubuntu1510:~$ sudo apt-get clean

apt-get命令示例

更新仓库

update参数用于从源头重新同步软件包索引文件。可用软件包的索引是从文件/etc/apt/sources.list中指定的位置获取的。在执行任何升级或dist-upgrade之前,应始终执行更新。

itr@ubuntu1510:~$ sudo apt-get update
[sudo] password for itr: 
Hit http://security.ubuntu.com wily-security InRelease
Hit http://gb.archive.ubuntu.com wily InRelease  
Hit http://gb.archive.ubuntu.com wily-updates InRelease               
Hit http://security.ubuntu.com wily-security/main Sources              

安装软件包

基本语法:sudo apt-get install packagename

itr@ubuntu1510:~$ sudo apt-get install htop
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed
  htop
0 to upgrade, 1 to newly install, 0 to remove and 7 not to upgrade.
Need to get 65.3 kB of archives.
After this operation, 203 kB of additional disk space will be used.
Get:1 http://gb.archive.ubuntu.com/ubuntu/ wily/universe htop amd64 1.0.3-1 [65.3 kB]
Fetched 65.3 kB in 0s (471 kB/s)

在此示例中,我们执行了命令sudo apt-get install htop。这里的htop是要安装的软件包的名称。

清理磁盘空间 - autoclean

可以使用autoclean参数清除检索到的软件包文件的本地存储库。自动清理仅删除不再下载的软件包文件,这些文件在很大程度上没有用。

itr@ubuntu1510:~$ sudo apt-get autoclean
Reading package lists... Done
Building dependency tree       

删除软件包及其配置文件

基本语法:sudo apt-get --purge remove 软件包名称

itr@ubuntu1510:~$ sudo apt-get --purge remove htop
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED
  htop*
0 to upgrade, 0 to newly install, 1 to remove and 7 not to upgrade.
日期:2019-04-29 03:17:30 来源:oir作者:oir