Linux

apt-cache is one useful command I always use when searching for things to install. However, there are a few more things this nifty command can do:

1. Search Packages

apt-cache search php-

The above command will search for packages that are available for installation. In this case, we searched for the php-apc package. It will output the name of the package along with a short description.

user@yourvps:~$ apt-cache search php-
libnet-libidn-perl - Perl bindings for GNU Libidn
php-mythtv - PHP Bindings for MythTV
bandwidthd-pgsql - Tracks usage of TCP/IP and builds html files with graphs
cakephp-instaweb - Development webserver for CakePHP applications
cakephp-scripts - MVC rapid application development framework for PHP (scripts)
dimp1 - dynamic webmail component for horde framework

2. Show List of Installable Packages

apt-cache pkgnames

The above command will list all packages that can be installed. It will output the name of the various packages. There will be no description.

user@yourvps:~$ apt-cache pkgnames
linux-backports-modules-cw-3.3-3.2.0-34-generic
linux-backports-modules-cw-3.3-3.2.0-29-generic
libc6-xen
python-sword-dbg
mumudvb
mpg123-alsa
libuuidm-ocaml-dev
libtexttools-doc
libsvm-java
libosmgpsmap2
libolap4j-java
libole-storage-lite-perl
firebird2.1-dev
...

3. Show Package Information

apt-cache show php-redis

The above command lets you see more information about the package. You will be able to see the version, size and developers.

user@yourvps:~$ apt-cache show php5-redis
Package: php5-redis
Source: php-redis
Priority: optional
Section: php
Installed-Size: 347
Maintainer: Debian PHP PECL Maintainers <pkg-php-pecl@lists.alioth.debian.org>
Architecture: amd64
Version: 2.2.4-1+debphp.org~precise+1
Suggests: redis-server
Depends: libc6 (>= 2.14), phpapi-20121212
Filename: pool/main/p/php-redis/php5-redis_2.2.4-1+debphp.org~precise+1_amd64.deb
Size: 123862
MD5sum: e7689f5c7fe63c14272688fda70897c0
SHA1: 161072ad8772498c96162272725d44fbbb73844b
SHA256: a52ea2f400036f70e563b8281e9a81c5120b0a8f858a12abaf581b6dbcf77e22
Description: PHP extension for interfacing with Redis
 This extension allows php applications to communicate with the Redis
 persistent key-value store. The php-redis module provides an easy object
 oriented interface.

What’s next?

There’s nothing next. Just try out the commands and see for yourself! Goodluck!