如果你知道包名稱,那麼你可以直接安裝所需的包。
在某些情況下,如果你不知道確切的包名稱或者你想搜尋某些包,那麼你可以在發行版的包管理器的幫助下輕鬆搜尋該包。搜尋會自動包括已安裝和可用的包。結果的格式取決於選項。如果你的查詢沒有輸出任何資訊,那麼意味著沒有匹配條件的包。這可以通過發行版的包管理器的各種選項來完成。我已經在本文中新增了所有可能的選項,你可以選擇最好的和最合適你的選項。
或者,我們可以通過 whohas
命令實現這一點。它會從所有的主流發行版(例如 Debian、Ubuntu、 Fedora 等)中搜尋,而不僅僅是你自己的系統發行版。
建議閱讀:
我們可以使用 apt
、apt-cache
和 aptitude
包管理器在基於 Debian 的發行版上查詢給定的包。我為這個包管理器中包括了大量的選項。
我們可以在基於 Debian 的系統中使用三種方式完成此操作。
apt
命令apt-cache
命令aptitude
命令APT 代表高階包管理工具(APT),它取代了 apt-get
。它有功能豐富的命令列工具,包括所有功能包含在一個命令(apt
)裡,包括 apt-cache
、apt-search
、dpkg
、apt-cdrom
、apt-config
、apt-key
等,還有其他幾個獨特的功能。
APT 是一個強大的命令列工具,它可以存取 libapt-pkg 底層庫的所有特性,它可以用於安裝、下載、刪除、搜尋和管理以及查詢包的資訊,另外它還包含一些較少使用的與包管理相關的命令列實用程式。
$ apt -q list nano vlcListing...nano/artful,now 2.8.6-3 amd64 [installed]vlc/artful 2.2.6-6 amd64
或者,我們可以使用以下格式搜尋指定的包。
$ apt search ^vlcSorting... DoneFull Text Search... Donevlc/artful 2.2.6-6 amd64 multimedia player and streamervlc-bin/artful 2.2.6-6 amd64 binaries from VLCvlc-data/artful,artful 2.2.6-6 all Common data for VLCvlc-l10n/artful,artful 2.2.6-6 all Translations for VLCvlc-plugin-access-extra/artful 2.2.6-6 amd64 multimedia player and streamer (extra access plugins)vlc-plugin-base/artful 2.2.6-6 amd64 multimedia player and streamer (base plugins)
apt-cache
會在 APT 的包快取上執行各種操作。它會顯示有關指定包的資訊。apt-cache
不會改變系統的狀態,但提供了從包的後設資料中搜尋和生成有趣輸出的操作。
$ apt-cache search nano | grep ^nanonano - small, friendly text editor inspired by Piconano-tiny - small, friendly text editor inspired by Pico - tiny buildnanoblogger - Small weblog engine for the command linenanoblogger-extra - Nanoblogger pluginsnanoc - static site generator written in Rubynanoc-doc - static site generator written in Ruby - documentationnanomsg-utils - nanomsg utilitiesnanopolish - consensus caller for nanopore sequencing data
或者,我們可以使用以下格式搜尋指定的包。
$ apt-cache policy vlcvlc: Installed: (none) Candidate: 2.2.6-6 Version table: 2.2.6-6 500 500 http://in.archive.ubuntu.com/ubuntu artful/universe amd64 Packages
或者,我們可以使用以下格式搜尋給定的包。
$ apt-cache pkgnames vlcvlc-binvlc-plugin-video-outputvlc-plugin-sdlvlc-plugin-svgvlc-plugin-sambavlc-plugin-fluidsynthvlc-plugin-qtvlc-plugin-skins2vlc-plugin-visualizationvlc-l10nvlc-plugin-notifyvlc-plugin-zvbivlc-plugin-vlsubvlc-plugin-jackvlc-plugin-access-extravlcvlc-datavlc-plugin-video-splittervlc-plugin-base
aptitude
是一個基於文字的 Debian GNU/Linux 軟體包系統的命令列介面。它允許使用者檢視包列表,並執行包管理任務,例如安裝、升級和刪除包,它可以從視覺化介面或命令列執行操作。
$ aptitude search ^vlcp vlc - multimedia player and streamer p vlc:i386 - multimedia player and streamer p vlc-bin - binaries from VLC p vlc-bin:i386 - binaries from VLC p vlc-data - Common data for VLC v vlc-data:i386 - p vlc-l10n - Translations for VLC v vlc-l10n:i386 - p vlc-plugin-access-extra - multimedia player and streamer (extra access plugins) p vlc-plugin-access-extra:i386 - multimedia player and streamer (extra access plugins) p vlc-plugin-base - multimedia player and streamer (base plugins) p vlc-plugin-base:i386 - multimedia player and streamer (base plugins) p vlc-plugin-fluidsynth - FluidSynth plugin for VLC p vlc-plugin-fluidsynth:i386 - FluidSynth plugin for VLC p vlc-plugin-jack - Jack audio plugins for VLC p vlc-plugin-jack:i386 - Jack audio plugins for VLC p vlc-plugin-notify - LibNotify plugin for VLC p vlc-plugin-notify:i386 - LibNotify plugin for VLC p vlc-plugin-qt - multimedia player and streamer (Qt plugin) p vlc-plugin-qt:i386 - multimedia player and streamer (Qt plugin) p vlc-plugin-samba - Samba plugin for VLC p vlc-plugin-samba:i386 - Samba plugin for VLC p vlc-plugin-sdl - SDL video and audio output plugin for VLC p vlc-plugin-sdl:i386 - SDL video and audio output plugin for VLC p vlc-plugin-skins2 - multimedia player and streamer (Skins2 plugin) p vlc-plugin-skins2:i386 - multimedia player and streamer (Skins2 plugin) p vlc-plugin-svg - SVG plugin for VLC p vlc-plugin-svg:i386 - SVG plugin for VLC p vlc-plugin-video-output - multimedia player and streamer (video output plugins) p vlc-plugin-video-output:i386 - multimedia player and streamer (video output plugins) p vlc-plugin-video-splitter - multimedia player and streamer (video splitter plugins) p vlc-plugin-video-splitter:i386 - multimedia player and streamer (video splitter plugins) p vlc-plugin-visualization - multimedia player and streamer (visualization plugins) p vlc-plugin-visualization:i386 - multimedia player and streamer (visualization plugins) p vlc-plugin-vlsub - VLC extension to download subtitles from opensubtitles.org p vlc-plugin-zvbi - VBI teletext plugin for VLC p vlc-plugin-zvbi:i386
Yum(Yellowdog Updater Modified)是 Linux 作業系統中的包管理器實用程式之一。Yum 命令用於在一些基於 RedHat 的 Linux 發行版上,它用來安裝、更新、搜尋和刪除軟體包。
# yum search ftpdLoaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfile * base: centos.hyve.com * epel: mirrors.coreix.net * extras: centos.hyve.com * rpmforge: www.mirrorservice.org * updates: mirror.sov.uk.goscomb.net============================================================== N/S Matched: ftpd ===============================================================nordugrid-arc-gridftpd.x86_64 : ARC gridftp serverpure-ftpd.x86_64 : Lightweight, fast and secure FTP servervsftpd.x86_64 : Very Secure Ftp Daemon Name and summary matches only, use "search all" for everything.
或者,我們可以使用以下命令搜尋相同內容。
# yum list ftpd
DNF 代表 Dandified yum。我們可以說 DNF 是下一代 yum 包管理器(Yum 的衍生品),它使用 hawkey/libsolv 庫作為底層。Aleš Kozumplík 從 Fedora 18 開始開發 DNF,最終在 Fedora 22 中發布。
# dnf search ftpdLast metadata expiration check performed 0:42:28 ago on Tue Jun 9 22:52:44 2018.============================== N/S Matched: ftpd ===============================proftpd-utils.x86_64 : ProFTPD - Additional utilitiespure-ftpd-selinux.x86_64 : SELinux support for Pure-FTPDproftpd-devel.i686 : ProFTPD - Tools and header files for developersproftpd-devel.x86_64 : ProFTPD - Tools and header files for developersproftpd-ldap.x86_64 : Module to add LDAP support to the ProFTPD FTP serverproftpd-mysql.x86_64 : Module to add MySQL support to the ProFTPD FTP serverproftpd-postgresql.x86_64 : Module to add PostgreSQL support to the ProFTPD FTP : servervsftpd.x86_64 : Very Secure Ftp Daemonproftpd.x86_64 : Flexible, stable and highly-configurable FTP serverowfs-ftpd.x86_64 : FTP daemon providing access to 1-Wire networksperl-ftpd.noarch : Secure, extensible and configurable Perl FTP serverpure-ftpd.x86_64 : Lightweight, fast and secure FTP serverpyftpdlib.noarch : Python FTP server librarynordugrid-arc-gridftpd.x86_64 : ARC gridftp server
或者,我們可以使用以下命令搜尋相同的內容。
# dnf list proftpdFailed to synchronize cache for repo 'heikoada-terminix', disabling.Last metadata expiration check: 0:08:02 ago on Tue 26 Jun 2018 04:30:05 PM IST.Available Packagesproftpd.x86_64
pacman 代表包管理實用程式(pacman)。它是一個用於安裝、構建、刪除和管理 Arch Linux 軟體包的命令列實用程式。pacman 使用 libalpm(Arch Linux Package Management(ALPM)庫)作為底層來執行所有操作。
在本例中,我將要搜尋 chromium 包。
# pacman -Ss chromiumextra/chromium 48.0.2564.116-1 The open-source project behind Google Chrome, an attempt at creating a safer, faster, and more stable browserextra/qt5-webengine 5.5.1-9 (qt qt5) Provides support for web applications using the Chromium browser projectcommunity/chromium-bsu 0.9.15.1-2 A fast paced top scrolling shootercommunity/chromium-chromevox latest-1 Causes the Chromium web browser to automatically install and update the ChromeVox screen reader extention. Note: This package does not contain the extension code.community/fcitx-mozc 2.17.2313.102-1 Fcitx Module of A Japanese Input Method for Chromium OS, Windows, Mac and Linux (the Open Source Edition of Google Japanese Input)
預設情況下,-s
選項內建 ERE(擴充套件正規表示式)會導致很多不需要的結果。使用以下格式會僅匹配包名稱。
# pacman -Ss '^chromium-'
pkgfile
是一個用於在 Arch Linux 官方倉庫的包中搜尋檔案的工具。
# pkgfile chromium
Zypper 是 SUSE 和 openSUSE 發行版的命令列包管理器。它用於安裝、更新、搜尋和刪除包以及管理倉庫,執行各種查詢等。Zypper 命令列對接到 ZYpp 系統管理庫(libzypp)。
# zypper search ftpor# zypper se ftpLoading repository data...Reading installed packages...S | Name | Summary | Type --+----------------+-----------------------------------------+-------- | proftpd | Highly configurable GPL-licensed FTP -> | package | proftpd-devel | Development files for ProFTPD | package | proftpd-doc | Documentation for ProFTPD | package | proftpd-lang | Languages for package proftpd | package | proftpd-ldap | LDAP Module for ProFTPD | package | proftpd-mysql | MySQL Module for ProFTPD | package | proftpd-pgsql | PostgreSQL Module for ProFTPD | package | proftpd-radius | Radius Module for ProFTPD | package | proftpd-sqlite | SQLite Module for ProFTPD | package | pure-ftpd | A Lightweight, Fast, and Secure FTP S-> | package | vsftpd | Very Secure FTP Daemon - Written from-> | package
whohas
命令是一個智慧工具,從所有主流發行版中搜尋指定包,如 Debian、Ubuntu、Gentoo、Arch、AUR、Mandriva、Fedora、Fink、FreeBSD 和 NetBSD。
$ whohas nanoMandriva nano-debug 2.3.1-1mdv2010.2.x http://sophie.zarb.org/rpms/0b33dc73bca710749ad14bbc3a67e15aMandriva nano-debug 2.2.4-1mdv2010.1.i http://sophie.zarb.org/rpms/d9dfb2567681e09287b27e7ac6cdbc05Mandriva nano-debug 2.2.4-1mdv2010.1.x http://sophie.zarb.org/rpms/3299516dbc1538cd27a876895f45aee4Mandriva nano 2.3.1-1mdv2010.2.x http://sophie.zarb.org/rpms/98421c894ee30a27d9bd578264625220Mandriva nano 2.3.1-1mdv2010.2.i http://sophie.zarb.org/rpms/cea07b5ef9aa05bac262fc7844dbd223Mandriva nano 2.2.4-1mdv2010.1.s http://sophie.zarb.org/rpms/d61f9341b8981e80424c39c3951067faMandriva spring-mod-nanoblobs 0.65-2mdv2010.0.sr http://sophie.zarb.org/rpms/74bb369d4cbb4c8cfe6f6028e8562460Mandriva nanoxml-lite 2.2.3-4.1.4mdv2010 http://sophie.zarb.org/rpms/287a4c37bc2a39c0f277b0020df47502Mandriva nanoxml-manual-lite 2.2.3-4.1.4mdv2010 http://sophie.zarb.org/rpms/17dc4f638e5e9964038d4d26c53cc9c6Mandriva nanoxml-manual 2.2.3-4.1.4mdv2010 http://sophie.zarb.org/rpms/a1b5092cd01fc8bb78a0f3ca9b90370bGentoo nano 9999 http://packages.gentoo.org/package/app-editors/nano Gentoo nano 9999 http://packages.gentoo.org/package/app-editors/nano Gentoo nano 2.9.8 http://packages.gentoo.org/package/app-editors/nano Gentoo nano 2.9.7
如果你希望只從當前發行版倉庫中搜尋指定包,使用以下格式:
$ whohas -d Ubuntu vlcUbuntu vlc 2.1.6-0ubuntu14.04 1M all http://packages.ubuntu.com/trusty/vlcUbuntu vlc 2.1.6-0ubuntu14.04 1M all http://packages.ubuntu.com/trusty-updates/vlcUbuntu vlc 2.2.2-5ubuntu0.16. 1M all http://packages.ubuntu.com/xenial/vlcUbuntu vlc 2.2.2-5ubuntu0.16. 1M all http://packages.ubuntu.com/xenial-updates/vlcUbuntu vlc 2.2.6-6 40K all http://packages.ubuntu.com/artful/vlcUbuntu vlc 3.0.1-3build1 32K all http://packages.ubuntu.com/bionic/vlcUbuntu vlc 3.0.2-0ubuntu0.1 32K all http://packages.ubuntu.com/bionic-updates/vlcUbuntu vlc 3.0.3-1 33K all http://packages.ubuntu.com/cosmic/vlcUbuntu browser-plugin-vlc 2.0.6-2 55K all http://packages.ubuntu.com/trusty/browser-plugin-vlcUbuntu browser-plugin-vlc 2.0.6-4 47K all http://packages.ubuntu.com/xenial/browser-plugin-vlcUbuntu browser-plugin-vlc 2.0.6-4 47K all http://packages.ubuntu.com/artful/browser-plugin-vlcUbuntu browser-plugin-vlc 2.0.6-4 47K all http://packages.ubuntu.com/bionic/browser-plugin-vlcUbuntu browser-plugin-vlc 2.0.6-4 47K all http://packages.ubuntu.com/cosmic/browser-plugin-vlcUbuntu libvlc-bin 2.2.6-6 27K all http://packages.ubuntu.com/artful/libvlc-binUbuntu libvlc-bin 3.0.1-3build1 17K all http://packages.ubuntu.com/bionic/libvlc-binUbuntu libvlc-bin 3.0.2-0ubuntu0.1 17K all