Linux Administration
medium

Questão de Linux Administration #019e3987

Enunciado da Questão
Linux Administration
#apt-get
#dpkg
#apt-cache
#package-management
Médio

Which of the following commands is used to update the list of available packages when using dpkg based package management?

A

apt-get update

Correta
B

apt-get upgrade

C

apt-cache update

D

apt-get refresh

E

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-cache is a tool for querying the APT cache (e.g., searching packages). There is no update subcommand; the correct command is apt-get update.
  • D. apt-get refresh: This is not a valid APT command. The correct term is update.
  • E. apt-cache upgrade: apt-cache does not have an upgrade subcommand. Upgrades are done via apt-get upgrade or apt-get dist-upgrade.