What is apt-get?

A powerful command-line utility used in Debian-based Linux distributions to handle the installation, upgrading, and removal of software packages while automatically resolving dependencies.

🌐 Termes dans d'autres langues:
Contenu en attente de traduction. Affichage de la version anglaise.

apt-get (Advanced Package Tool) is the primary low-level interface for the Debian package management system. It acts as a wrapper around dpkg, the tool that actually installs .deb files. The strength of apt-get lies in its ability to fetch packages from remote Repositories, verify their integrity using GPG keys, and solve complex graphs of Dependencies—ensuring that if a program requires specific libraries to run, they are downloaded and configured first. While the newer apt command is preferred for interactive desktop use because of its progress bars and simplified syntax, apt-get remains the gold standard for server automation, Dockerfiles, and system scripting due to its stable CLI output and professional-grade options like --assume-yes and --purge.

        graph LR
  Center["What is apt-get?"]:::main
  Pre_linux["linux"]:::pre --> Center
  click Pre_linux "/terms/linux"
  Rel_bash["bash"]:::related -.-> Center
  click Rel_bash "/terms/bash"
  Rel_npm["npm"]:::related -.-> Center
  click Rel_npm "/terms/npm"
  Rel_crypto_wallet["crypto-wallet"]:::related -.-> Center
  click Rel_crypto_wallet "/terms/crypto-wallet"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧒 Explique-moi comme si j'avais 5 ans

Think of apt-get as a very efficient librarian for your [Linux](/fr/terms/linux) computer. When you say 'I want to read this book' (install an app), the librarian doesn't just find the book; they also find all the other reference materials you'll need to understand it, check that none of the pages are forged, and put everything neatly on your shelf. It's the App Store, but for engineers.

🤓 Expert Deep Dive

Senior DevOps engineers treat apt-get as an Imperative Infrastructure tool.

### 1. Dependency Resolution and libapt-pkg:
apt-get uses a sophisticated state-engine provided by libapt-pkg. When you run dist-upgrade, it builds a directed acyclic graph (DAG) of every package on your system. If a new version of a package conflicts with an old library, apt-get uses a scoring algorithm to decide whether to upgrade, hold, or remove packages to maintain system consistency.

### 2. The local Cache and /var/lib/apt/lists/:
Before any installation, apt-get update synchronizes the local package index with the remote repositories. These index files are stored in /var/lib/apt/lists/. Without this sync, apt-get will attempt to download versions of software that may no longer exist on the server, leading to 404 errors during installation.

### 3. Security: GPG and the Trusted Keychain:
Every package in a Debian repository is signed. apt-get uses GPG to verify these signatures against the local 'trusted' keychain. If a repository has been compromised or a man-in-the-middle attack is occurring, the signature check will fail, and apt-get will refuse to install the software unless explicitly forced (which is a high-risk action).

### 4. Cleaning and Optimization:
Because apt-get downloads packages to /var/cache/apt/archives/ before installing them, servers can quickly run out of disk space. Commands like autoremove (to delete unused dependencies) and clean (to clear the archive cache) are essential for long-term server maintenance in Docker and Cloud-init environments.

🔗 Termes associés

Prérequis:

📚 Sources