I have some questions about the APT package manager.
As I understand we have repositories URLs located at /etc/apt/sources.list
and /etc/apt/sources.list.d/*
When apt-get update
is called, apt tries to connect to all specified repositories in the file and download information about those repositories about what programs are available and so on.
It caches all retrieved data locally in order to use it later without making internet requests to the repository.
When apt-get install
is called it searches local cache package list from available repositories and if package is not found it does nothing except display an error.
apt-get search
also looks into local cache and doesn't make any requests to the internet.
Am I right? I am not sure about commands that make requests instead of searching data in the local cache.
Also, what is the difference between apt-cache search
and apt search
? I can guess they both use the local cache.
You are right that apt-get update
reads from the sources (online) and the other commands apt-get search
and apt-get install
read from the cached information. From man apt
:
update (apt-get(8))
update is used to download package information from all configured
sources. Other commands operate on this data to e.g. perform
package upgrades or search in and display details about all
packages available for installation.
The difference between apt search
and apt-cache search
is that the output of apt search
is fancier (has colours, alphabetically organised, has nice line separation for easy reading) because apt is a fancy new interface. This is explained well in this answer on the difference between apt & apt-get
However, search isn't the only thing you can do with apt-cache:
Usage: apt-cache [options] command
apt-cache [options] show pkg1 [pkg2 ...]
apt-cache queries and displays available information about installed
and installable packages. It works exclusively on the data acquired
into the local cache via the 'update' command of e.g. apt-get. The
displayed information may therefore be outdated if the last update was
too long ago, but in exchange apt-cache works independently of the
availability of the configured sources (e.g. offline).
Most used commands:
showsrc - Show source records
search - Search the package list for a regex pattern
depends - Show raw dependency information for a package
rdepends - Show reverse dependency information for a package
show - Show a readable record for the package
pkgnames - List the names of all packages in the system
policy - Show policy settings
This is from the info
page for apt-cache
apt
combines commands from apt-get
and apt-cache
, so you can get the same or slightly fancier/tidied up output from any of the apt-cache [option]
commands with apt [option]
eg
apt show gimp
displays almost exactly the same as
apt-cache show gimp
No comments:
Post a Comment