如何在Debian,Ubuntu或Linux Mint中从命令行查找可用软件包 [APT]

有几种方法可以从命令行搜索可用于Debian,Ubuntu或Linux Mint的软件包。在本文中, aptapt-cacheaptitude。使用它来查找软件包名称和软件包描述。如果您正在寻找特定的程序包,但不知道确切的程序包名称,或者需要用于特定目的/任务的工具,则知道可用的选项。
使用上的主要差异 aptapt-cacheaptitude 如下面的示例所示,搜索可用软件包的是输出和排序顺序。还有 aptitude 默认情况下,它可能未安装在基于Debian的Linux发行版上。
我个人喜欢 apt-cache 输出是可读的(通常不需要其他信息,以查看可用的已安装/可用版本) apt-cache policy package-name另外,您要寻找的结果往往会出现在顶部附近。
另一个警告是 aptapt-cache 搜索apt软件包缓存,以返回存储库中可用的软件包和手动安装的DEB软件包(存储库中不可用)。 aptitude 仅返回存储库中可用的软件包。使用aptitude搜索可用的软件包aptitude 基于Ncurses的前端 apt。通常,默认情况下未安装此工具,但是您可以使用以下命令将其安装在Debian,Ubuntu,Linux Mint和其他基于Debian的Linux发行版上:

sudo apt install aptitude

您可以使用aptitude从命令行中搜索软件包,如下所示:

aptitude search KEYWORD

范例:

$ aptitude search openssh

p   libconfig-model-openssh-perl                           - configuration editor for OpenSsh                                
p   libghc-crypto-pubkey-openssh-dev                       - OpenSSH key codec  
p   libghc-crypto-pubkey-openssh-dev:i386                  - OpenSSH key codec  
v   libghc-crypto-pubkey-openssh-dev-0.2.7-6af0a           -                    
v   libghc-crypto-pubkey-openssh-dev-0.2.7-6af0a:i386      -                    
p   libghc-crypto-pubkey-openssh-doc                       - OpenSSH key codec; documentation                                
p   libghc-crypto-pubkey-openssh-prof                      - OpenSSH key codec; profiling libraries                          
p   libghc-crypto-pubkey-openssh-prof:i386                 - OpenSSH key codec; profiling libraries                          
v   libghc-crypto-pubkey-openssh-prof-0.2.7-6af0a          -                    
v   libghc-crypto-pubkey-openssh-prof-0.2.7-6af0a:i386     -                    
p   libnet-openssh-compat-perl                             - collection of compatibility modules for Net::OpenSSH            
p   libnet-openssh-parallel-perl                           - run SSH jobs in parallel                                        
p   libnet-openssh-perl                                    - Perl SSH client package implemented on top of OpenSSH           
p   lxqt-openssh-askpass                                   - OpenSSH user/password GUI dialog for LXQt                       
p   lxqt-openssh-askpass:i386                              - OpenSSH user/password GUI dialog for LXQt                       
p   lxqt-openssh-askpass-l10n                              - Language package for lxqt-openssh-askpass                       
v   lxqt-openssh-askpass-l10n:i386                         -                    
i   openssh-client                                         - secure shell (SSH) client, for secure access to remote machines 
p   openssh-client:i386                                    - secure shell (SSH) client, for secure access to remote machines 
p   openssh-client-ssh1                                    - secure shell (SSH) client for legacy SSH1 protocol              
p   openssh-client-ssh1:i386                               - secure shell (SSH) client for legacy SSH1 protocol              
p   openssh-known-hosts                                    - download, filter and merge known_hosts for OpenSSH
p   openssh-server                                         - secure shell (SSH) server, for secure access from remote machines
p   openssh-server:i386                                    - secure shell (SSH) server, for secure access from remote machines 
p   openssh-sftp-server                                    - secure shell (SSH) sftp server module, for SFTP access from remote machines
p   openssh-sftp-server:i386                               - secure shell (SSH) sftp server module, for SFTP access from remote machines

如果需要,您还可以使用aptitude Ncurses UI。型式 aptitude 开始使用:

按下搜索包裹 / 接下来,开始输入关键字。搜索可用的软件包 apt-cache
使用方法 apt-cache 要在Debian,Ubuntu或Linux Mint存储库中搜索可用的软件包(以及存储库中未安装的DEB软件包),如下所示:

apt-cache search KEYWORD

范例:

$ apt-cache search openssh

openssh-client - secure shell (SSH) client, for secure access to remote machines
openssh-server - secure shell (SSH) server, for secure access from remote machines
openssh-sftp-server - secure shell (SSH) sftp server module, for SFTP access from remote machines
python-setproctitle - Setproctitle implementation for Python 2
python3-setproctitle - Setproctitle implementation for Python 3
ssh - secure shell client and server (metapackage)
agent-transfer - copy a secret key from GnuPG's gpg-agent to OpenSSH's ssh-agent

...

ssh-askpass-gnome - interactive X program to prompt users for a passphrase for ssh-add
ssh-audit - tool for ssh server auditing
sshpass - Non-interactive ssh password authentication

一些输出已删除,因为它可能很长。但是,显示结果的顺序没有改变。搜索可用的软件包 apt
使用 apt 您可以从命令行搜索可用的软件包,如下所示:

apt search KEYWORD

用您的搜索词替换“关键字”(您可以在多个关键字中加上引号)。
以下是“ openssh”及其输出的搜索示例。

$ apt search openssh

Sorting... Done
Full Text Search... Done
agent-transfer/bionic 0.41-1ubuntu1 amd64
  copy a secret key from GnuPG's gpg-agent to OpenSSH's ssh-agent

cme/bionic,bionic 1.026-1 all
  Check or edit configuration data with Config::Model

connect-proxy/bionic 1.105-1 amd64
  Establish TCP connection using SOCKS4/5 or HTTP tunnel

...

openssh-client/bionic,now 1:7.6p1-4 amd64 [installed]
  secure shell (SSH) client, for secure access to remote machines

openssh-client-ssh1/bionic 1:7.5p1-10 amd64
  secure shell (SSH) client for legacy SSH1 protocol

openssh-known-hosts/bionic,bionic 0.6.2-1 all
  download, filter and merge known_hosts for OpenSSH

openssh-server/bionic 1:7.6p1-4 amd64
  secure shell (SSH) server, for secure access from remote machines

openssh-sftp-server/bionic 1:7.6p1-4 amd64
  secure shell (SSH) sftp server module, for SFTP access from remote machines

putty-tools/bionic 0.70-4 amd64
  command-line tools for SSH, SCP, and SFTP

python-scp/bionic,bionic 0.10.2-1 all
  scp module for paramiko

同样,结果列表很长,以至于某些结果已被删除。但是,结果的顺序没有改变。
对于这三个而言,搜索结果可能会很长。在这种情况下,您可以运行它们 more为了提高可读性,如下:

apt-cache search KEYWORD | more

您还可以排除不包含特定关键字的结果(在此示例中为KEYWORD2) grep

apt-cache search KEYWORD | grep KEYWORD2

grep 默认值区分大小写。新增 -igrep -i KEYWORD2忽略大小写。

Sidebar