Questão de Linux Administration #019e3987
Which of the following commands is used to update the list of available packages when using dpkg based package management?
apt-get update
apt-get upgrade
apt-cache update
apt-get refresh
apt-cache upgrade
Explicação Oficial / Explicações da Comunidade
Summary
The question asks which command updates the list of available packages in a dpkg-based system (like Debian, Ubuntu). The correct answer is apt-get update. This command refreshes the local package index from repositories, allowing the system to know about new versions and new packages. It does not install or upgrade anything.
How it Works
dpkg is the low-level package manager that installs, removes, and queries .deb packages. However, it does not handle dependencies or repository metadata. Tools like apt-get (from APT) work on top of dpkg. When you run apt-get update, APT reads the /etc/apt/sources.list file and files in /etc/apt/sources.list.d/, contacts each repository, downloads the updated Packages.gz (or similar) index files, and stores them in /var/lib/apt/lists/. This index contains metadata about all available packages (names, versions, dependencies, etc.). Without this update, the system has an outdated view of what is available.
Why the correct answer is right
apt-get update is the standard command to synchronize the package index files from their sources. It is the first step before performing an upgrade or installing new packages to ensure you have the latest information.
Why incorrect options are wrong
- B.
apt-get upgrade: This command actually upgrades all installed packages to their newest versions based on the current index. It does not update the index itself. - C.
apt-cache update:apt-cacheis a tool for querying the APT cache (e.g., searching packages). There is noupdatesubcommand; the correct command isapt-get update. - D.
apt-get refresh: This is not a valid APT command. The correct term isupdate. - E.
apt-cache upgrade:apt-cachedoes not have anupgradesubcommand. Upgrades are done viaapt-get upgradeorapt-get dist-upgrade.