加入收藏 | 设为首页 | 会员中心 | 我要投稿 源码网 (https://www.900php.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Windows > 正文

如何在安装之前检查Linux软件包的版本?

发布时间:2019-08-20 09:37:33 所属栏目:Windows 来源:Sk
导读:副标题#e# 大多数人都知道如何在 Linux 中查找已安装软件包的版本,但是,你会如何查找那些还没有安装的软件包的版本呢?很简单!本文将介绍在 Debian 及其衍生品(如 Ubuntu)中,如何在软件包安装之前检查它的版本。对于那些想在安装之前知道软件包版本的

要查看软件包的版本而不安装它,我们可以使用 apt-get 命令和 -s 选项。

  1. $ apt-get -s install vim

示例输出:

  1. NOTE: This is only a simulation!
  2. apt-get needs root privileges for real execution.
  3. Keep also in mind that locking is deactivated,
  4. so don't depend on the relevance to the real current situation!
  5. Reading package lists... Done
  6. Building dependency tree
  7. Reading state information... Done
  8. Suggested packages:
  9. ctags vim-doc vim-scripts
  10. The following NEW packages will be installed:
  11. vim
  12. 0 upgraded, 1 newly installed, 0 to remove and 45 not upgraded.
  13. Inst vim (2:8.0.1453-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64])
  14. Conf vim (2:8.0.1453-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64])

这里,-s 选项代表 模拟。正如你在输出中看到的,它不执行任何操作。相反,它只是模拟执行,好让你知道在安装 Vim 时会发生什么。

你可以将 install 选项替换为 upgrade,以查看升级包时会发生什么。

  1. $ apt-get -s upgrade vim

方法 3 – 使用 Aptitude

在 Debian 及其衍生品中,aptitude 是一个基于 ncurses(LCTT 译注:ncurses 是终端基于文本的字符处理的库)和命令行的前端 APT 包管理器。

使用 aptitude 来查看软件包的版本,只需运行:

  1. $ aptitude versions vim
  2. p 2:8.0.1453-1ubuntu1 bionic 500
  3. p 2:8.0.1453-1ubuntu1.1 bionic-security,bionic-updates 500

你还可以使用模拟选项(-s)来查看安装或升级包时会发生什么。

  1. $ aptitude -V -s install vim
  2. The following NEW packages will be installed:
  3. vim [2:8.0.1453-1ubuntu1.1]
  4. 0 packages upgraded, 1 newly installed, 0 to remove and 45 not upgraded.
  5. Need to get 1,152 kB of archives. After unpacking 2,852 kB will be used.
  6. Would download/install/remove packages.

这里,-V 标志用于显示软件包的详细信息。

  1. $ aptitude -V -s upgrade vim

类似的,只需将 install 替换为 upgrade 选项,即可查看升级包会发生什么。

  1. $ aptitude search vim -F "%c %p %d %V"

这里,

  • -F 用于指定应使用哪种格式来显示输出,
  • %c – 包的状态(已安装或未安装),
  • %p – 包的名称,
  • %d – 包的简介,
  • %V – 包的版本。

当你不知道完整的软件包名称时,这非常有用。这个命令将列出包含给定字符串(即 vim)的所有软件包。

以下是上述命令的示例输出:

  1. [...]
  2. p vim Vi IMproved - enhanced vi editor 2:8.0.1453-1ub
  3. p vim-tlib Some vim utility functions 1.23-1
  4. p vim-ultisnips snippet solution for Vim 3.1-3
  5. p vim-vimerl Erlang plugin for Vim 1.4.1+git20120
  6. p vim-vimerl-syntax Erlang syntax for Vim 1.4.1+git20120
  7. p vim-vimoutliner script for building an outline editor on top of Vim 0.3.4+pristine
  8. p vim-voom Vim two-pane outliner 5.2-1
  9. p vim-youcompleteme fast, as-you-type, fuzzy-search code completion engine for Vim 0+20161219+git

方法 4 – 使用 Apt-cache

apt-cache 命令用于查询基于 Debian 的系统中的 APT 缓存。对于要在 APT 的包缓存上执行很多操作时,它很有用。一个很好的例子是我们可以从某个仓库或 ppa 中列出已安装的应用程序。

(编辑:源码网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读