Linux "apt-cache" Command Line Options and Examples
query the APT cache

apt-cache performs a variety of operations on APT's package cache. apt-cache does not manipulate the state of the system but does provide operations to search and generate interesting output from the package metadata. The metadata is acquired and updated via the 'update' command of e.


Usage:

apt-cache [-agipns] [-o=config_string] [-c=config_file] {gencaches | showpkg pkg... | showsrc pkg... | stats | dump | dumpavail |
unmet | search regex... | show pkg [{=pkg_version_number | /target_release}]... |
depends pkg [{=pkg_version_number | /target_release}]... | rdepends pkg [{=pkg_version_number | /target_release}]... |
pkgnames [prefix] | dotty pkg [{=pkg_version_number | /target_release}]... |
xvcg pkg [{=pkg_version_number | /target_release}]... | policy [pkg...] | madison pkg... | {-v | --version} |
{-h | --help}}






Command Line Options:

-p
Select the file to store the package cache. The package cache is the primary cache used by all operations. Configuration Item:Dir::Cache::pkgcache.
apt-cache -p ...
-s
Select the file to store the source cache. The source is used only by gencaches and it stores a parsed version of the packageinformation from remote sources. When building the package cache the source cache is used to avoid reparsing all of the packagefiles. Configuration Item: Dir::Cache::srcpkgcache.
apt-cache -s ...
-q
Quiet; produces output suitable for logging, omitting progress indicators. More q's will produce more quietness up to a maximumof 2. You can also use -q=# to set the quietness level, overriding the configuration file. Configuration Item: quiet.
apt-cache -q ...
-i
Print only important dependencies; for use with unmet and depends. Causes only Depends and Pre-Depends relations to be printed.Configuration Item: APT::Cache::Important.
apt-cache -i ...
--no-pre-depends
Per default the depends and rdepends print all dependencies. This can be tweaked with these flags which will omit the specifieddependency type. Configuration Item: APT::Cache::ShowDependencyType e.g. APT::Cache::ShowRecommends.
apt-cache --no-pre-depends ...
--implicit
Per default depends and rdepends print only dependencies explicitly expressed in the metadata. With this flag it will also showdependencies implicitly added based on the encountered data. A Conflicts: foo e.g. expresses implicitly that this package alsoconflicts with the package foo from any other architecture. Configuration Item: APT::Cache::ShowImplicit.
apt-cache --implicit ...
-f
Print full package records when searching. Configuration Item: APT::Cache::ShowFull.
apt-cache -f ...
-a
Print full records for all available versions. This is the default; to turn it off, use --no-all-versions. If --no-all-versionsis specified, only the candidate version will be displayed (the one which would be selected for installation). This option isonly applicable to the show command. Configuration Item: APT::Cache::AllVersions.
apt-cache -a ...
-g
Perform automatic package cache regeneration, rather than use the cache as it is. This is the default; to turn it off, use
apt-cache -g ...
--no-generate.
Configuration Item: APT::Cache::Generate.
apt-cache --no-generate. ...
--names-only
Only search on the package and provided package names, not the long descriptions. Configuration Item: APT::Cache::NamesOnly.
apt-cache --names-only ...
--all-names
Make pkgnames print all names, including virtual packages and missing dependencies. Configuration Item: APT::Cache::AllNames.
apt-cache --all-names ...
--recurse
Make depends and rdepends recursive so that all packages mentioned are printed once. Configuration Item:APT::Cache::RecurseDepends.
apt-cache --recurse ...
--installed
Limit the output of depends and rdepends to packages which are currently installed. Configuration Item: APT::Cache::Installed.
apt-cache --installed ...
--with-source
Adds the given file as a source for metadata. Can be repeated to add multiple files. Supported are currently *.deb, *.dsc,*.changes, Sources and Packages files as well as source package directories. Files are matched based on their name only, nottheir content!Sources and Packages can be compressed in any format apt supports as long as they have the correct extension. If you need tostore multiple of these files in one directory you can prefix a name of your choice with the last character being an underscore("_"). Example: my.example_Packages.xzNote that these sources are treated as trusted (see apt-secure(8)). Configuration Item: APT::Sources::With.
apt-cache --with-source ...
-h
Show a short usage summary.
apt-cache -h ...
-v
Show the program version.
apt-cache -v ...
-c
Configuration File; Specify a configuration file to use. The program will read the default configuration file and then thisconfiguration file. If configuration settings need to be set before the default configuration files are parsed specify a filewith the APT_CONFIG environment variable. See apt.conf(5) for syntax information.
apt-cache -c ...
-o
Set a Configuration Option; This will set an arbitrary configuration option. The syntax is -o Foo::Bar=bar. -o and --option canbe used multiple times to set different options.FILES/etc/apt/sources.listLocations to fetch packages from. Configuration Item: Dir::Etc::SourceList./etc/apt/sources.list.d/File fragments for locations to fetch packages from. Configuration Item: Dir::Etc::SourceParts./var/lib/apt/lists/Storage area for state information for each package resource specified in sources.list(5) Configuration Item: Dir::State::Lists./var/lib/apt/lists/partial/Storage area for state information in transit. Configuration Item: Dir::State::Lists (partial will be implicitly appended)
apt-cache -o ...