Is there a way to check if a program is available in the repository by commandline?
You can use any one of these commands,
apt-cache search <package_name>
aptitude search <package_name>
apt-cache policy <package_name>
sudo apt-get install <package_name> -s
Output:
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
You can install apt-file
which allows you to search for file names in APT. For instances to find a binary 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
It breaks down by package: file match
apt-cache search
is what you want:
For example:
apt-cache search firefox
will return things with firefox in it. From the manpage:
search performs a full text search on all available package lists for the POSIX regex pattern given, see regex(7). It searches the package names and the descriptions for an occurrence of the regular expression and prints out the package name and the short description, including virtual package names. If --full is given then output identical to show is produced for each matched package, and if --names-only is given then the long description is not searched, only the package name is.
Separate arguments can be used to specify multiple search patterns that are and'ed together.