当前位置: 首页>>技术教程>>正文


我如何搜索命令行中的可用软件包?

, ,

问题描述

当我事先知道这些软件包可用时,我已经使用命令行’sudo apt-get install …’成功安装了一些软件包。但是,我如何搜索或获取存储库中可用内容的列表?

最佳解决方案

按名称或说明搜索特定的软件包:

从命令行中,使用:

apt-cache search keyword

搜索关键字可以是包名称或其描述中使用的任何单词的全部或部分。

例如,apt-cache search proxy包含这两个包:


tinyproxy - A lightweight, non-caching, optionally anonymizing HTTP proxy
tircd - ircd proxy to the twitter API

Note: the list may be long, so you can pipe the output to less to make it scrollable one line or one screen at a time, i.e. apt-cache search something | less.

获取所有软件包的列表

apt-cache search .

如果您启用了X-forwarding或位于桌面上,请使用新立得

突触通常是一种更方便的方法,但至少需要一台X服务器(除非您正在运行桌面环境)。必要时使用sudo apt-get install synaptic安装。

  • 通过X转发在sshd服务器上的突触:

    command-line,apt,ubuntu

  • 在Ubuntu桌面上本地运行Synaptic:

    command-line,apt,ubuntu

次佳解决方案

您还可以使用命令行中的aptitude:

aptitude search xxxxxx

第三种解决方案

使用aptitudeapt-cacheapt都会以不同的方式格式化输出。 (这些都不需要在搜索包时使用sudo。)为了可读性,我更喜欢使用apt。它突出显示软件包名称并在不同软件包之间放置一个空格。它还有[installed]列在已安装的每个软件包旁边。用法:

apt search package-name

第四种方案

The apt-cache command line tool is used for searching apt software package cache. In simple words, this tool is used to search software packages, collects information of packages and also used to search for what available packages are ready for installation on Debian or Ubuntu based systems.

要在安装之前找出软件包名称及其描述,请使用“搜索”标志。在apt-cache中使用“search”将显示一个简短描述的匹配包列表。假设您想查看软件包’vsftpd’的描述,那么命令将会是。

Syntax:

apt-cache search SearchTerm 
$ apt-cache search vsftpd

The possible output would be:

vsftpd - lightweight, efficient FTP server written for security
ccze - A robust, modular log coloriser
ftpd - File Transfer Protocol (FTP) server
yasat - simple stupid audit tool

To find and list down all the packages starting with ‘vsftpd‘, you could use the following command.

$ apt-cache pkgnames vsftpd

You may also want to run the results through a more, or even a grep. For instance:

apt-cache search firefox | grep plugin

第五种方案

假设您想从终端执行所有这些操作,请使用以下命令:

首先,我建议您更新软件包索引文件,以便将要创建的存储库中的所有文件列表都是最新的

sudo apt-get update

然后在apt-cache中使用”search regex”函数,其中”regex”表示正则表达式,并且是给予搜索的模式。有关搜索模式的更多信息,您可以通过命令man 7 regex或在English中查找手动正则表达式(7)。一个正则表达式变量等于。就足够了。

apt-cache search .

以上将给你所有的结果,但它不是以任何顺序对浏览特别有用。

最后,我们可以使用sort -d按字典顺序进行排序,并使用less一次只显示一个页面。

apt-cache search . |sort -d |less

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/46.html,未经允许,请勿转载。