皇上,还记得我吗?我就是1999年那个Linux伊甸园啊-----24小时滚动更新开源资讯,全年无休!

如何在 Linux 上检查一个软件包的详细信息

我们可以就这个已经被广泛讨论的话题写出大量的文章,大多数情况下,因为各种各样的原因,我们都愿意让包管理器package manager来帮我们做这些事情。

每个 Linux 发行版都有自己的包管理器,并且每个都有各自有不同的特性,这些特性包括允许用户执行安装新软件包,删除无用的软件包,更新现存的软件包,搜索某些具体的软件包,以及更新整个系统到其最新的状态之类的操作。

习惯于命令行的用户大多数时间都会使用基于命令行方式的包管理器。对于 Linux 而言,这些基于命令行的包管理器有 yumdnfrpmaptapt-getdpkgpacman 和 zypper

推荐阅读

作为一个系统管理员你应该清楚地知道:安装包来自何方,具体来自哪个软件仓库,包的具体版本,包的大小,版本,包的源代码 URL,包的许可证信息,等等。

这篇短文将用尽可能简单的方式帮你从随包自带的总结和描述中了解该包的用法。按你所使用的 Linux 发行版的不同,运行下面相应的命令,你能得到你所使用的发行版下的包的详细信息。

YUM 命令:在 RHEL 和 CentOS 系统上获得包的信息

YUM 英文直译是“黄狗更新器–修改版Yellowdog Updater, Modified”,它是一个开源的基于命令行的包管理器前端实用工具。它被广泛应用在基于 RPM 的系统上,例如:RHEL 和 CentOS。

Yum 是用于在官方发行版仓库以及其他第三方发行版仓库下获取、安装、删除、查询 RPM 包的主要工具。

(LCTT 译注:用 yum info 获取 python 包的信息)

  1. # yum info python
  2. Loaded plugins: fastestmirror, security
  3. Loading mirror speeds from cached hostfile
  4. * epel: epel.mirror.constant.com
  5. Installed Packages
  6. Name : python
  7. Arch : x86_64
  8. Version : 2.6.6
  9. Release : 66.el6_8
  10. Size : 78 k
  11. Repo : installed
  12. From repo : updates
  13. Summary : An interpreted, interactive, object-oriented programming language
  14. URL : http://www.python.org/
  15. License : Python
  16. Description : Python is an interpreted, interactive, object-oriented programming
  17. : language often compared to Tcl, Perl, Scheme or Java. Python includes
  18. : modules, classes, exceptions, very high level dynamic data types and
  19. : dynamic typing. Python supports interfaces to many system calls and
  20. : libraries, as well as to various windowing systems (X11, Motif, Tk,
  21. : Mac and MFC).
  22. :
  23. : Programmers can write new built-in modules for Python in C or C++.
  24. : Python can be used as an extension language for applications that need
  25. : a programmable interface.
  26. :
  27. : Note that documentation for Python is provided in the python-docs
  28. : package.
  29. :
  30. : This package provides the "python" executable; most of the actual
  31. : implementation is within the "python-libs" package.

YUMDB 命令:查看 RHEL 和 CentOS 系统上的包信息

yumdb info 这个命令提供与 yum info 相类似的的信息,不过它还额外提供了诸如包校验值、包类型、用户信息(由何人安装)。从 yum 3.2.26 版本后,yum 开始在 rpm 数据库外储存额外的信息了(此处如显示 user表明该包由用户安装,而 dep 说明该包是被作为被依赖的包而被安装的)。

(LCTT 译注:用 yumdb info 来获取 python 包的信息)

  1. # yumdb info python
  2. Loaded plugins: fastestmirror
  3. python-2.6.6-66.el6_8.x86_64
  4. changed_by = 4294967295
  5. checksum_data = 53c75a1756e5b4f6564c5229a37948c9b4561e0bf58076bd7dab7aff85a417f2
  6. checksum_type = sha256
  7. command_line = update -y
  8. from_repo = updates
  9. from_repo_revision = 1488370672
  10. from_repo_timestamp = 1488371100
  11. installed_by = 4294967295
  12. reason = dep
  13. releasever = 6

RPM 命令:在 RHEL/CentOS/Fedora 系统上查看包的信息

RPM 英文直译为“红帽包管理器Red Hat Package Manager”,这是一个在 RedHat 以及其变种发行版(如RHEL、CentOS、Fedora、openSUSE、Megeia)下的功能强大的命令行包管理工具。它能让你轻松的安装、升级、删除、查询以及校验你的系统或服务器上的软件。RPM 文件以 .rpm 结尾。RPM 包由它所依赖的软件库以及其他依赖构成,它不会与系统上已经安装的包冲突。

(LCTT 译注:用 rpm -qi 查询 nano 包的具体信息)

  1. # rpm -qi nano
  2. Name : nano Relocations: (not relocatable)
  3. Version : 2.0.9 Vendor: CentOS
  4. Release : 7.el6 Build Date: Fri 12 Nov 2010 02:18:36 AM EST
  5. Install Date: Fri 03 Mar 2017 08:57:47 AM EST Build Host: c5b2.bsys.dev.centos.org
  6. Group : Applications/Editors Source RPM: nano-2.0.9-7.el6.src.rpm
  7. Size : 1588347 License: GPLv3+
  8. Signature : RSA/8, Sun 03 Jul 2011 12:46:50 AM EDT, Key ID 0946fca2c105b9de
  9. Packager : CentOS BuildSystem
  10. URL : http://www.nano-editor.org
  11. Summary : A small text editor
  12. Description :
  13. GNU nano is a small and friendly text editor.

DNF 命令:在 Fedora 系统上查看包信息

DNF 指“时髦版的 YumDandified yum”,我们也可以认为 DNF 是下一代的 yum 包管理器(Yum 的一个分支),它在后台使用了 hawkey/libsolv 库。Aleš Kozumplík 在Fedora 18 上开始开发 DNF,在 Fedora 22 上正式最后发布。 dnf 命令用来在 Fedora 22 及以后的系统上安装、更新、搜索以及删除包。它能自动的解决包安装过程中的包依赖问题。

(LCTT 译注: 用 dnf info 查看 tilix 包信息)

  1. $ dnf info tilix
  2. Last metadata expiration check: 27 days, 10:00:23 ago on Wed 04 Oct 2017 06:43:27 AM IST.
  3. Installed Packages
  4. Name : tilix
  5. Version : 1.6.4
  6. Release : 1.fc26
  7. Arch : x86_64
  8. Size : 3.6 M
  9. Source : tilix-1.6.4-1.fc26.src.rpm
  10. Repo : @System
  11. From repo : @commandline
  12. Summary : Tiling terminal emulator
  13. URL : https://github.com/gnunn1/tilix
  14. License : MPLv2.0 and GPLv3+ and CC-BY-SA
  15. Description : Tilix is a tiling terminal emulator with the following features:
  16. :
  17. : - Layout terminals in any fashion by splitting them horizontally or vertically
  18. : - Terminals can be re-arranged using drag and drop both within and between
  19. : windows
  20. : - Terminals can be detached into a new window via drag and drop
  21. : - Input can be synchronized between terminals so commands typed in one
  22. : terminal are replicated to the others
  23. : - The grouping of terminals can be saved and loaded from disk
  24. : - Terminals support custom titles
  25. : - Color schemes are stored in files and custom color schemes can be created by
  26. : simply creating a new file
  27. : - Transparent background
  28. : - Supports notifications when processes are completed out of view
  29. :
  30. : The application was written using GTK 3 and an effort was made to conform to
  31. : GNOME Human Interface Guidelines (HIG).

Zypper 命令:在 openSUSE 系统上查看包信息

zypper 是一个使用 libzypp 库的命令行包管理器。zypper 提供诸如软件仓库访问,安装依赖解决,软件包安装等等功能。

(LCTT 译注: 用 zypper info 查询 nano 包的信息)

  1. $ zypper info nano
  2. Loading repository data...
  3. Reading installed packages...
  4. Information for package nano:
  5. -----------------------------
  6. Repository : Main Repository (OSS)
  7. Name : nano
  8. Version : 2.4.2-5.3
  9. Arch : x86_64
  10. Vendor : openSUSE
  11. Installed Size : 1017.8 KiB
  12. Installed : No
  13. Status : not installed
  14. Source package : nano-2.4.2-5.3.src
  15. Summary : Pico editor clone with enhancements
  16. Description :
  17. GNU nano is a small and friendly text editor. It aims to emulate
  18. the Pico text editor while also offering a few enhancements.

Pacman 命令:在 ArchLinux 及 Manjaro 系统上查看包信息

Pacman 意即包管理器package manager实用工具。pacman 是一个用于安装、构建、删除、管理 Arch Linux 上包的命令行工具。它后端使用 libalpm(Arch Linux package Manager(ALPM)库)来完成所有功能。

(LCTT 译注: 用 pacman -Qi 来查询 bash 包信息)

  1. $ pacman -Qi bash
  2. Name : bash
  3. Version : 4.4.012-2
  4. Description : The GNU Bourne Again shell
  5. Architecture : x86_64
  6. URL : http://www.gnu.org/software/bash/bash.html
  7. Licenses : GPL
  8. Groups : base
  9. Provides : sh
  10. Depends On : readline>=7.0 glibc ncurses
  11. Optional Deps : bash-completion: for tab completion
  12. Required By : autoconf automake bison bzip2 ca-certificates-utils db
  13. dhcpcd diffutils e2fsprogs fakeroot figlet findutils
  14. flex freetype2 gawk gdbm gettext gmp grub gzip icu
  15. iptables keyutils libgpg-error libksba libpcap libpng
  16. libtool lvm2 m4 man-db mkinitcpio nano neofetch nspr
  17. nss openresolv os-prober pacman pcre pcre2 shadow
  18. systemd texinfo vte-common which xdg-user-dirs xdg-utils
  19. xfsprogs xorg-mkfontdir xorg-xpr xz
  20. Optional For : None
  21. Conflicts With : None
  22. Replaces : None
  23. Installed Size : 7.13 MiB
  24. Packager : Jan Alexander Steffens (heftig)
  25. Build Date : Tue 14 Feb 2017 01:16:51 PM UTC
  26. Install Date : Thu 24 Aug 2017 06:08:12 AM UTC
  27. Install Reason : Explicitly installed
  28. Install Script : No
  29. Validated By : Signature

apt-cache 命令:在 Debian/Ubuntu/Mint 系统上查看包信息

apt-cache 命令能显示 apt 内部数据库中的大量信息。这些信息是从 sources.list 中的不同的软件源中搜集而来,因此从某种意义上这些信息也可以被认为是某种缓存。这些信息搜集工作是在运行 apt update 命令时执行的。

(LCTT 译注:用管理员权限查询 apache2 包的信息)

  1. $ sudo apt-cache show apache2
  2. Package: apache2
  3. Priority: optional
  4. Section: web
  5. Installed-Size: 473
  6. Maintainer: Ubuntu Developers
  7. Original-Maintainer: Debian Apache Maintainers
  8. Architecture: amd64
  9. Version: 2.4.12-2ubuntu2
  10. Replaces: apache2.2-common
  11. Provides: httpd, httpd-cgi
  12. Depends: lsb-base, procps, perl, mime-support, apache2-bin (= 2.4.12-2ubuntu2), apache2-utils (>= 2.4), apache2-data (= 2.4.12-2ubuntu2)
  13. Pre-Depends: dpkg (>= 1.17.14)
  14. Recommends: ssl-cert
  15. Suggests: www-browser, apache2-doc, apache2-suexec-pristine | apache2-suexec-custom, ufw
  16. Conflicts: apache2.2-common (<< 2.3~)
  17. Filename: pool/main/a/apache2/apache2_2.4.12-2ubuntu2_amd64.deb
  18. Size: 91348
  19. MD5sum: ab0ee0b0d1c6b3d19bd87aa2a9537125
  20. SHA1: 350c9a1a954906088ed032aebb77de3d5bb24004
  21. SHA256: 03f515f7ebc3b67b050b06e82ebca34b5e83e34a528868498fce020bf1dbbe34
  22. Description-en: Apache HTTP Server
  23. The Apache HTTP Server Project's goal is to build a secure, efficient and
  24. extensible HTTP server as standards-compliant open source software. The
  25. result has long been the number one web server on the Internet.
  26. .
  27. Installing this package results in a full installation, including the
  28. configuration files, init scripts and support scripts.
  29. Description-md5: d02426bc360345e5acd45367716dc35c
  30. Homepage: http://httpd.apache.org/
  31. Bugs: https://bugs.launchpad.net/ubuntu/+filebug
  32. Origin: Ubuntu
  33. Supported: 9m
  34. Task: lamp-server, mythbuntu-frontend, mythbuntu-desktop, mythbuntu-backend-slave, mythbuntu-backend-master, mythbuntu-backend-master

APT 命令:查看 Debian/Ubuntu/Mint 系统上的包信息

APT 意为高级打包工具Advanced Packaging Tool,就像 DNF 将如何替代 YUM 一样,APT 是 apt-get 的替代物。它功能丰富的命令行工具包括了如下所有命令的功能如 apt-cacheapt-searchdpkgapt-cdromapt-configapt-key 等等,我们可以方便的通过 apt 来安装 .dpkg 包,但是我们却不能通过 apt-get 来完成这一点,还有一些其他的类似的功能也不能用 apt-get 来完成,所以 apt-get 因为没有解决上述功能缺乏的原因而被 apt 所取代。

(LCTT 译注: 用 apt show 查看 nano 包信息)

  1. $ apt show nano
  2. Package: nano
  3. Version: 2.8.6-3
  4. Priority: standard
  5. Section: editors
  6. Origin: Ubuntu
  7. Maintainer: Ubuntu Developers
  8. Original-Maintainer: Jordi Mallach
  9. Bugs: https://bugs.launchpad.net/ubuntu/+filebug
  10. Installed-Size: 766 kB
  11. Depends: libc6 (>= 2.14), libncursesw5 (>= 6), libtinfo5 (>= 6)
  12. Suggests: spell
  13. Conflicts: pico
  14. Breaks: nano-tiny (<< 2.8.6-2)
  15. Replaces: nano-tiny (<< 2.8.6-2), pico
  16. Homepage: https://www.nano-editor.org/
  17. Task: standard, ubuntu-touch-core, ubuntu-touch
  18. Supported: 9m
  19. Download-Size: 222 kB
  20. APT-Manual-Installed: yes
  21. APT-Sources: http://in.archive.ubuntu.com/ubuntu artful/main amd64 Packages
  22. Description: small, friendly text editor inspired by Pico
  23. GNU nano is an easy-to-use text editor originally designed as a replacement
  24. for Pico, the ncurses-based editor from the non-free mailer package Pine
  25. (itself now available under the Apache License as Alpine).
  26. .
  27. However, GNU nano also implements many features missing in pico, including:
  28. - undo/redo
  29. - line numbering
  30. - syntax coloring
  31. - soft-wrapping of overlong lines
  32. - selecting text by holding Shift
  33. - interactive search and replace (with regular expression support)
  34. - a go-to line (and column) command
  35. - support for multiple file buffers
  36. - auto-indentation
  37. - tab completion of filenames and search terms
  38. - toggling features while running
  39. - and full internationalization support

dpkg 命令:查看Debian/Ubuntu/Mint系统上的包信息

dpkg 意指 Debian 包管理器Debian package managerdpkg 是用于 Debian 系统上安装、构建、移除以及管理 Debian 包的命令行工具。dpkg 使用 aptitude(因为它更为主流及用户友好)作为前端工具来完成所有的功能。其他的工具如dpkg-deb 和 dpkg-query 使用 dpkg 做为前端来实现功能。尽管系统管理员还是时不时会在必要时使用 dpkg 来完成一些软件安装的任务,他大多数情况下还是会因为 aptapt-get 以及 aptitude 的健壮性而使用后者。

(LCTT 译注: 用 dpkg -s 查看 python 包的信息)

  1. $ dpkg -s python
  2. Package: python
  3. Status: install ok installed
  4. Priority: optional
  5. Section: python
  6. Installed-Size: 626
  7. Maintainer: Ubuntu Developers
  8. Architecture: amd64
  9. Multi-Arch: allowed
  10. Source: python-defaults
  11. Version: 2.7.14-2ubuntu1
  12. Replaces: python-dev (<< 2.6.5-2)
  13. Provides: python-ctypes, python-email, python-importlib, python-profiler, python-wsgiref
  14. Depends: python2.7 (>= 2.7.14-1~), libpython-stdlib (= 2.7.14-2ubuntu1)
  15. Pre-Depends: python-minimal (= 2.7.14-2ubuntu1)
  16. Suggests: python-doc (= 2.7.14-2ubuntu1), python-tk (>= 2.7.14-1~)
  17. Breaks: update-manager-core (<< 0.200.5-2)
  18. Conflicts: python-central (<< 0.5.5)
  19. Description: interactive high-level object-oriented language (default version)
  20. Python, the high-level, interactive object oriented language,
  21. includes an extensive class library with lots of goodies for
  22. network programming, system administration, sounds and graphics.
  23. .
  24. This package is a dependency package, which depends on Debian's default
  25. Python version (currently v2.7).
  26. Homepage: http://www.python.org/
  27. Original-Maintainer: Matthias Klose

我们也可使用 dpkg 的 -p 选项,这个选项提供和 dpkg -s 相类似的信息,但是它还提供了包的校验值和包类型。

(LCTT 译注: 用 dpkg -p 查看 python3 包的信息)

  1. $ dpkg -p python3
  2. Package: python3
  3. Priority: important
  4. Section: python
  5. Installed-Size: 67
  6. Origin: Ubuntu
  7. Maintainer: Ubuntu Developers
  8. Bugs: https://bugs.launchpad.net/ubuntu/+filebug
  9. Architecture: amd64
  10. Multi-Arch: allowed
  11. Source: python3-defaults
  12. Version: 3.6.3-0ubuntu2
  13. Replaces: python3-minimal (<< 3.1.2-2)
  14. Provides: python3-profiler
  15. Depends: python3.6 (>= 3.6.3-1~), libpython3-stdlib (= 3.6.3-0ubuntu2), dh-python
  16. Pre-Depends: python3-minimal (= 3.6.3-0ubuntu2)
  17. Suggests: python3-doc (>= 3.6.3-0ubuntu2), python3-tk (>= 3.6.3-1~), python3-venv (>= 3.6.3-0ubuntu2)
  18. Filename: pool/main/p/python3-defaults/python3_3.6.3-0ubuntu2_amd64.deb
  19. Size: 8712
  20. MD5sum: a8bae494c6e5d1896287675faf40d373
  21. Description: interactive high-level object-oriented language (default python3 version)
  22. Original-Maintainer: Matthias Klose
  23. SHA1: 2daec885cea7d4dc83c284301c3bebf42b23e095
  24. SHA256: 865e509c91d2504a16c4b573dbe27e260c36fceec2add3fa43a30c1751d7e9bb
  25. Homepage: http://www.python.org/
  26. Task: minimal, ubuntu-core, ubuntu-core
  27. Description-md5: 950ebd8122c0a7340f0a740c295b9eab
  28. Supported: 9m

aptitude 命令:查看 Debian/Ubuntu/Mint 系统上的包信息

aptitude 是 Debian GNU/Linux 包管理系统的文本界面。它允许用户查看已安装的包的列表,以及完成诸如安装、升级、删除包之类的包管理任务。这些管理行为也能从图形接口来执行。

(LCTT 译注: 用 aptitude show 查看 htop 包信息)

  1. $ aptitude show htop
  2. Package: htop
  3. Version: 2.0.2-1
  4. State: installed
  5. Automatically installed: no
  6. Priority: optional
  7. Section: universe/utils
  8. Maintainer: Ubuntu Developers
  9. Architecture: amd64
  10. Uncompressed Size: 216 k
  11. Depends: libc6 (>= 2.15), libncursesw5 (>= 6), libtinfo5 (>= 6)
  12. Suggests: lsof, strace
  13. Conflicts: htop:i386
  14. Description: interactive processes viewer
  15. Htop is an ncursed-based process viewer similar to top, but it allows one to scroll the list vertically and horizontally to see all processes and their full command lines.
  16. Tasks related to processes (killing, renicing) can be done without entering their PIDs.
  17. Homepage: http://hisham.hm/htop/

via: https://www.2daygeek.com/how-to-view-detailed-information-about-a-package-in-linux/

作者:Prakash Subramanian 选题:lujun9972 译者:DavidChenLiang 校对:wxy

本文由 LCTT 原创编译,Linux中国 荣誉推出

编译自:https://www.2daygeek.com/how-to-view-detailed-information-about-a-package-in-linux/作者: Prakash Subramanian
原创:LCTT https://linux.cn/article-10018-1.html译者: DavidChenLiang