虽然在图形包管理器的帮助下包管理显得愈发容易,但一些用户总是更喜欢命令行形式。有不同的命令可以在不同的Linux版本中找出包版本。明天,在本教程中,我们将见到怎样在一些流行的Linux发行版中找到软件包版本,比如AlpineLinux、ArchLinux及其衍生产品、Debian及其衍生产品、RHEL及其衍生产品。
在AlpineLinux中查找软件包版本
要查看软件包版本和其他详尽信息linux系统版本命令,请使用apkinfo如下命令。
$ apk info vim
您将见到给定包的简略描述及其托管网站。
示例输出:
vim-8.2.2137-r0 description:
Improved vi-style text editor
vim-8.2.2137-r0 webpage:
https://www.vim.org/
vim-8.2.2137-r0 installed size:
18 MiB
gvim-8.2.2137-r0 description:
advanced text editor, with GUI
gvim-8.2.2137-r0 webpage:
https://www.vim.org/
gvim-8.2.2137-r0 installed size:
29 MiB
如您所见,安装的Vim版本是8.2.
在基于Arch的系统中查找软件包版本
要在ArchLinux及其衍生产品(如EndeavourOS和ManjaroLinux)中查找已安装的软件包(比如VLC)版本,请运行以下命令:
$ pacman -Q vlc
示例输出:
vlc 2.2.4-3
正如你在前面的输出中见到的linux 删除文件,VLC包的安装版本是2.2.4-3。
要显示包的详尽信息,请运行:
$ pacman -Qi vlc
示例输出:
Name : vlc
Version : 2.2.4-3
Description : A multi-platform MPEG, VCD/DVD, and DivX player
Architecture : x86_64
URL : http://www.videolan.org/vlc/
Licenses : LGPL2.1 GPL2
Groups : None
Provides : None
Depends On : a52dec libdvbpsi libxpm libdca libproxy sdl_image
libdvdnav libtiger lua libmatroska zvbi taglib
libmpcdec ffmpeg2.8 faad2 libupnp libshout libmad
libmpeg2 xcb-util-keysyms libtar libxinerama
Optional Deps : avahi: for service discovery using bonjour protocol
[installed]
libnotify: for notification plugin [installed]
gtk2: for notify plugin [installed]
[...]
lua-socket: for http interface
qt4: for the GUI [installed]
Required By : None
Optional For : smtube
Conflicts With : vlc-plugin
Replaces : vlc-plugin
Installed Size : 53.28 MiB
Packager : Antonio Rojas
Build Date : Sun 24 Jul 2016 03:12:59 PM IST
Install Date : Fri 05 Aug 2016 11:22:54 AM IST
Install Reason : Explicitly installed
Install Script : No
Validated By : Signature
在基于DEB的系统中查找包版本
在Debian、Ubuntu及其衍生产品(比如LinuxMint、PopOS和ElementaryOS)中linux系统版本命令,我们可以找到已安装的软件包,诸如Apachewebserver,使用dpkg带有-l开关的命令的版本如下:
$ dpkg -l apache2
或则,您可以使用dpkgwithgrep命令来获取安装版本的软件包,如下所示。
$ dpkg -s apache2 | grep -i version
示例输出:
Version: 2.4.18-2ubuntu3.1
要显示已安装软件包的详尽信息linux系统怎么样,请运行:
$ dpkg -s apache2
示例输出:
Package: apache2
Status: install ok installed
Priority: optional
Section: httpd
Installed-Size: 488
Maintainer: Ubuntu Developers
Architecture: amd64
Version: 2.4.18-2ubuntu3.1
Replaces: apache2.2-bin, apache2.2-common
Provides: httpd, httpd-cgi
Depends: lsb-base, procps, perl, mime-support, apache2-bin (= 2.4.18-2ubuntu3.1), apache2-utils (>= 2.4), apache2-data (= 2.4.18-2ubuntu3.1)
Pre-Depends: dpkg (>= 1.17.14)
Recommends: ssl-cert
Suggests: www-browser, apache2-doc, apache2-suexec-pristine | apache2-suexec-custom, ufw
Conflicts: apache2.2-bin, apache2.2-common
Conffiles:
/etc/apache2/apache2.conf da32fcc6a783acaebf0d74c17c726bf7
/etc/default/apache-htcacheclean ae8721a0bc5b4e2ef7a5258b1e9db5c5
[..]

/etc/logrotate.d/apache2 7322a4f050c1e2454249695236a3472c
/etc/ufw/applications.d/apache2-utils.ufw.profile f8d4fd920e598ceb4379613c6261f6af
Description: Apache HTTP Server
The Apache HTTP Server Project's goal is to build a secure, efficient and
extensible HTTP server as standards-compliant open source software. The
result has long been the number one web server on the Internet.
.
Installing this package results in a full installation, including the
configuration files, init scripts and support scripts.
Homepage: http://httpd.apache.org/
Original-Maintainer: Debian Apache Maintainers
据悉,我们可以使用以下apt-show-versions命令查找软件包版本:
$ apt-show-versions apache2
示例输出:
apache2:amd64/xenial-security 2.4.18-2ubuntu3.1 uptodate
apache2:i386 not installed
如上结果所示,我安装了apache264位版本,版本为2.4.18。
若果没有安装'apt-show-versions'程序,您可以使用以下命令安装它:
$ sudo apt install apt-show-versions
我们如今晓得怎样检测已安装软件包的版本。在线储存库中的软件包版本怎样?无论怎么要检测官方储存库中可用的软件包版本?这也是可能的。查看以下链接以了解操作技巧。
虽然这种软件包没有安装在基于Debian的系统中,您依然可以找到它们的版本。查看以下手册了解更多详情。
在基于RPM的系统中查找软件包版本
要在基于RPM的发行版(诸如RedHat、CentOS、Fedora、AlmaLinux、RockyLinux和openSUSE等)中找出已安装软件包(比如httpd)的版本,请运行:
$ rpm -qi httpd
示例输出:
Name : httpd
Version : 2.4.6
Release : 40.el7.centos.4
Architecture: x86_64
Install Date: Thu 11 Aug 2016 08:08:45 PM IST
Group : System Environment/Daemons
Size : 9806117
License : ASL 2.0
Signature : RSA/SHA256, Mon 18 Jul 2016 09:35:16 PM IST, Key ID 24c6a8a7f4a80eb5
Source RPM : httpd-2.4.6-40.el7.centos.4.src.rpm
Build Date : Mon 18 Jul 2016 09:02:11 PM IST
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem
Vendor : CentOS
URL : http://httpd.apache.org/
Summary : Apache HTTP Server
Description :
The Apache HTTP Server is a powerful, efficient, and extensible
web server.
里面的命令显示安装的包版本、构建日期、许可证、描述等。正如你在输出中见到的,httpd包版本是2.4.6。