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

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

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

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

答案1

您可以使用以下任意一个命令,

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

您可以安装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 正则表达式对所有可用包列表执行全文搜索,请参阅正则表达式(7)。它会在软件包名称和描述中搜索正则表达式,并打印出软件包名称和简短描述,包括虚拟软件包名称。如果指定了 --full,则每个匹配的软件包都会产生与 show 相同的输出,如果指定了 --names-only,则不会搜索长描述,只会搜索软件包名称。

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

相关内容