检查 Ubuntu/Debian 上已安装软件包的版本检查 Ubuntu/Debian 上已安装软件包的版本检查 Ubuntu/Debian 上已安装软件包的版本检查 Ubuntu/Debian 上已安装软件包的版本
  • 业务
  • 目标
  • 支持
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容

检查 Ubuntu/Debian 上已安装软件包的版本

发表 admin at 2025年2月28日
类别
  • 未分类
标签

我发现很多人问一个问题“如何检查 Ubuntu/Debian 系统上已安装软件包的版本?”,我如何知道 Ubuntu/Debian Linux 操作系统上可用的软件包版本?。在 Linux 中,所有应用程序都作为包分发,这些包只不过是与包管理系统关联的文件。本指南将向您展示一些可用于检查 Ubuntu/Debian Linux 计算机上的软件包版本的命令。

基于 Debian 的 Linux 系统附带两个主要的包管理器:

  • apt – 管理存储库中的包
  • dpkg  – 管理下载到系统的软件包。通常采用.deb格式
  • aptitude 的安装和使用方式与 apt 类似

要检查 Ubuntu 服务器/桌面上已安装软件包的版本,请使用下一节中显示的任何方法。

在开始之前更新您的软件包 APT 索引:

sudo apt update

方法一:使用apt命令

apt 命令有一个选项列表,您可以使用它来检查 Ubuntu 或 Debian 系统上安装的软件包的版本。

例如,要检查 Ubuntu/Debian 服务器上安装的curl 软件包的版本,我将运行:

$ apt list curl
Listing... Done
curl/jammy-updates,jammy-security,now 7.81.0-1ubuntu1.13 amd64 [installed]

要查看存储库中可用的软件包的所有版本,请传递-a选项。

$ apt list curl -a
Listing... Done
curl/jammy-updates,jammy-security,now 7.81.0-1ubuntu1.13 amd64 [installed]
curl/jammy 7.81.0-1 amd64

这包括存储库中可供安装的所有其他软件包。

有关该软件包的更多详细信息,请使用apt show。

$ apt show curl
Package: curl
Version: 7.81.0-1ubuntu1.13
Priority: optional
Section: web
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email >
Original-Maintainer: Alessandro Ghedini <[email >
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 454 kB
Depends: libc6 (>= 2.34), libcurl4 (= 7.81.0-1ubuntu1.13), zlib1g (>= 1:1.1.4)
Homepage: https://curl.haxx.se
Task: server-minimal, cloud-image, ubuntu-wsl, server, ubuntu-server-raspi, ubuntustudio-publishing, ubuntu-budgie-desktop, ubuntu-budgie-desktop-raspi
Download-Size: 194 kB
APT-Manual-Installed: yes
APT-Sources: https://mirror.hetzner.com/ubuntu/packages jammy-updates/main amd64 Packages
Description: command line tool for transferring data with URL syntax
 curl is a command line tool for transferring data with URL syntax, supporting
 DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3,
 POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP.
 .
 curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form
 based upload, proxies, cookies, user+password authentication (Basic, Digest,
 NTLM, Negotiate, kerberos...), file transfer resume, proxy tunneling and a
 busload of other useful tricks.

有关 docker-ce 软件包所有版本的详细信息,请使用:

apt show docker-ce  -a

方法 2:使用 apt-cache

apt-cache 是一个 Debian 命令行工具,用于查询 APT 缓存。它提供了从包元数据中搜索和生成有趣输出的操作。要使用 apt-cache 搜索软件包版本,请运行:

$ apt-cache policy curl
curl:
  Installed: 7.81.0-1ubuntu1.13
  Candidate: 7.81.0-1ubuntu1.13
  Version table:
 *** 7.81.0-1ubuntu1.13 500
        500 https://mirror.hetzner.com/ubuntu/packages jammy-updates/main amd64 Packages
        500 https://mirror.hetzner.com/ubuntu/security jammy-security/main amd64 Packages
        100 /var/lib/dpkg/status
     7.81.0-1 500
        500 https://mirror.hetzner.com/ubuntu/packages jammy/main amd64 Packages

$ apt-cache policy mariadb-server
mariadb-server:
  Installed: (none)
  Candidate: 1:10.6.12-0ubuntu0.22.04.1
  Version table:
     1:10.6.12-0ubuntu0.22.04.1 500
        500 https://mirror.hetzner.com/ubuntu/packages jammy-updates/universe amd64 Packages
        500 https://mirror.hetzner.com/ubuntu/security jammy-security/universe amd64 Packages
     1:10.6.7-2ubuntu1 500
        500 https://mirror.hetzner.com/ubuntu/packages jammy/universe amd64 Packages

第一行显示已安装的版本。如果未安装该软件包,您将看到 Installed 键的值为 none :

  Installed: (none)

其他行提供有关存储库中其他可用包的信息。使用apt-cache madison将给出相同的输出。

$ apt-cache madison curl
      curl | 7.81.0-1ubuntu1.13 | https://mirror.hetzner.com/ubuntu/packages jammy-updates/main amd64 Packages
      curl | 7.81.0-1ubuntu1.13 | https://mirror.hetzner.com/ubuntu/security jammy-security/main amd64 Packages
      curl |   7.81.0-1 | https://mirror.hetzner.com/ubuntu/packages jammy/main amd64 Packages

方法 3:使用 aptitude

Ubuntu 不附带 aptitude,您可以使用以下命令安装它:

sudo apt update
sudo apt install aptitude -y

要检查可用的软件包版本,请运行:

$ aptitude versions curl
p   7.81.0-1                                                                                                 jammy                                                                                500
i   7.81.0-1ubuntu1.13                                                                                       jammy-security,jammy-updates                                                         500

方法 4:使用 apt-show-versions

apt-show-versions 命令用于列出可用的软件包版本。安装包:

sudo apt update
sudo apt install apt-show-versions -y

使用命令查询已安装的包版本:

$ apt-show-versions curl
curl:amd64/jammy-security 7.81.0-1ubuntu1.13 uptodate

系统中未安装的软件包的输出:

$ apt-show-versions mariadb-server
mariadb-server:all not installed

带 grep 过滤器的 dpkg 命令可以显示已安装软件包的版本:

$ dpkg -s curl | grep Version
Version: 7.81.0-1ubuntu1.13

享受使用 Ubuntu/Debian Linux 是您的发行版选择。

推荐阅读的 Linux 书籍:

  • 适合初学者和专家的最佳 Linux 书籍
  • 最佳 Linux 内核编程书籍
  • 最佳 Linux Bash 脚本书籍
  • 顶级 RHCSA/RHCE 认证学习书籍
  • 最受好评的 CompTIA A+ 认证书籍
  • 最佳 LPIC-1 和 LPIC-2 认证学习书籍
©2015-2025 Norria support@norria.com