有没有一种方法可以通过命令行检查程序在存储库中是否可用?


12

当我找到一个有趣的程序时,我想测试并安装在ubuntu中,我首先检查它是否在存储库中可用。为此,我使用软件中心。

但是是否存在通过命令行(如apt或aptitude)进行检查的可能性?类似的apt get install命令?

Answers:


14

您可以使用以下任何命令,

apt-cache search <package_name>

aptitude search <package_name>

apt-cache policy <package_name>

sudo apt-get install <package_name> -s

输出:

karthick@Ubuntu-desktop:~$ sudo apt-get install sun-java6-jdk -s
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package sun-java6-jdk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package sun-java6-jdk has no installation candidate

2
您可以在关键字前面加上前缀^以表示开始于,例如aptitude search ^deb,它将列出包名称以开头deb而不是包含deb。正则表达式中可能还有更多控制字符,但我不知道了。
谢雷(YièJìléi)2010年

4

您可以安装apt-file它,以便在APT中搜索文件名。对于查找二进制文件的实例nagios

marco@marco-desktop:~$ sudo apt-file search nagios3
aide-common: /usr/share/aide/config/aide/aide.conf.d/31_aide_nagios3
cherokee-doc: /usr/share/doc/cherokee-doc/media/images/cookbook_nagios3.png
nagios-images: /usr/share/nagios3/htdocs/images/logos/andrade
nagios-images: /usr/share/nagios3/htdocs/images/logos/base
nagios-images: /usr/share/nagios3/htdocs/images/logos/bernhard
nagios-images: /usr/share/nagios3/htdocs/images/logos/cook
nagios-images: /usr/share/nagios3/htdocs/images/logos/didier
nagios-images: /usr/share/nagios3/htdocs/images/logos/remus
nagios-images: /usr/share/nagios3/htdocs/images/logos/satrapa
nagios-images: /usr/share/nagios3/htdocs/images/logos/werschler
nagios3: /usr/share/doc/nagios3
nagios3: /usr/share/lintian/overrides/nagios3
nagios3-cgi: /etc/nagios3/cgi.cfg
nagios3-cgi: /etc/nagios3/stylesheets/avail.css
nagios3-cgi: /etc/nagios3/stylesheets/checksanity.css
nagios3-cgi: /etc/nagios3/stylesheets/cmd.css
nagios3-cgi: /etc/nagios3/stylesheets/common.css
nagios3-cgi: /etc/nagios3/stylesheets/config.css

它分解为 package: file match


3

apt-cache search 是您想要的:

例如:

apt-cache search firefox

将返回带有Firefox的东西。从联机帮助页

search在给定的POSIX regex模式的所有可用软件包列表上执行全文搜索,请参见regex(7)。它在软件包名称和描述中搜索正则表达式的出现,并打印出软件包名称和简短描述,包括虚拟软件包名称。如果给定--full,则为每个匹配的软件包产生与show相同的输出;如果给定--names-only,则不搜索长描述,仅软件包名称。

可以使用单独的参数来指定多个“和”在一起的搜索模式。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.