Debian APT Tutorial 2026: apt, apt-get, aptitude
Table of Contents
📖 Preamble
In the Debian ecosystem — Stable, Testing or Sid — APT (Advanced Package Tool) is the central software management tool. It relies on dpkg for individual package manipulation and provides a powerful interface to install, update and remove software, while automatically managing dependencies.
/image%2F7127247%2F20260227%2Fob_b6a50a_apt.png)
This guide uses Debian 13 "trixie" as the Stable base, with Testing (forky) and Sid (unstable) as development branches. All commands and examples are verified for trixie.
Master APT progressively, from beginner to expert, with concrete practical use cases and verified commands.
👥 Target Audience
Sections: Starter Pack
Sections : Concepts & Pratiques
Sections : Avancé & Critiques
📚 How to Read This Guide
| Level | Content | Recommendation |
|---|---|---|
| 🟢 Essential | Common commands, examples | Master first |
| 🟠 Intermediate | Concepts, workflows | For deeper understanding |
| 🔴 Expert | Critical cases, advanced operations | For experienced users only |
❓ What is APT?
| Element | Description |
|---|---|
| Role | Package manager for Debian and its derivatives |
| Engine | Based on dpkg |
| Strengths | Automatic dependency resolution, fine-grained repository management, stability, community |
| Audience | All Debian users, from beginners to administrators |
📝 Basic Syntax
General Structure
Breakdown
| Element | Role | Example |
|---|---|---|
| OPTIONS | Options applied to the command | -y, --simulate, -V |
| COMMAND | The main action to perform | install, remove, update, upgrade |
| ARGUMENTS | What the action applies to | Package name, version, .deb file |
Annotated Example
🧩 Distinction entre apt, apt-get, apt-cache et aptitude
| Tool | Main Role | Interface | Audience |
|---|---|---|---|
| apt | Common user commands | Concise, colorful | Daily use |
| apt-get | Legacy package management | Bare, scripts | Automation |
| apt-cache | Cache querying | Command lines | Advanced searches |
| aptitude | Interactive text interface + CLI | Cursor/line mode | Complex conflict resolution |
Recommendation: apt for interactive use, apt-get for scripts, apt-cache for precise queries, aptitude as a last resort.
🏗️ Internal Architecture: APT + dpkg
┌────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ APT │ ──▶ │ dpkg │ ──▶ │ Linux System │
└────────────┘ └──────────────────┘ └──────────────────┘
│ │ │
▼ ▼ ▼
CLI Interface Installation/Removal File Management
Repository Mgmt Package database Maintainer scripts
Dependency of installed packages
resolutionComponent Roles
| Component | Role | Importance |
|---|---|---|
| APT | User interface, repository management, dependency resolution | Daily interaction |
| dpkg | Actual installation, local database | System core |
| Pinning | Repository priority control | Stability / customization |
📦 Repositories
Repository Role: The Foundation of Everything
Repositories are defined in /etc/apt/sources.list and /etc/apt/sources.list.d/.
┌─────────────────────┐
│ Debian 13 trixie │ (main, contrib, non-free, non-free-firmware)
└─────────────────────┘
│
┌─────────────────────┐
│ Debian Security │ (security updates)
└─────────────────────┘
│
┌─────────────────────┐
│ trixie-updates │ (stable updates)
└─────────────────────┘
│
┌─────────────────────┐
│ trixie-backports │ (more recent versions, targeted use)
└─────────────────────┘Repository Types
| Type | Content | Notes |
|---|---|---|
| main | Official free packages | Supported by Debian |
| contrib | Free packages depending on non-free ones | |
| non-free | Non-free packages | Proprietary drivers |
| non-free-firmware | Proprietary firmware (WiFi, GPU, microcode) | Required for much modern hardware — Debian 13+ |
| security | Security patches | Essential for Stable |
| backports | Recent versions for Stable | Official, targeted use (not for the whole system) |
| experimental | Very fresh, unstable packages | For testing only |
Repository Lifecycle
Ajouter manuellement │ ▼ Modifier (éditer le fichier) │ ▼ Activer / Désactiver (commenter) │ ▼ Supprimer (effacer la ligne)
DEB822 Format — Recommended for Debian 13
Debian 13 trixie favors files in /etc/apt/sources.list.d/*.sources in DEB822 format to declare repositories. The sources.list format remains supported for compatibility.
Best Practices by Use Case
| Distribution | Recommended Repositories | Discouraged Repositories |
|---|---|---|
| Stable (trixie) | main, contrib, non-free, non-free-firmware, security, trixie-updates | experimental — backports: official but targeted use only |
| Testing (forky) | main, contrib, non-free, non-free-firmware | experimental (may desynchronize) |
| Sid | main, contrib, non-free, non-free-firmware | backports (useless on Sid) |
| Servers | main, non-free-firmware, security, trixie-updates | contrib, non-free if possible |
⚖️ Repository Priorities (Pinning)
The APT priority system lets you control which repository takes precedence.
APT doit installer un paquet :
│
▼
1. Dépôt avec la priorité la plus élevée
│
▼
2. Version la plus récente (si priorités égales)
│
▼
3. Dependency resolution- P < 0: never installed
- 1-99: only if no other version is installed
- 100: default priority for already installed version
- 101-499: only if no higher priority source exists
- 500: standard priority of the target distribution
- 501-989: only if no newer version in the target
- 990-1000: unless installed version is more recent
- >1000: always installed, even if forced downgrade
🔄 Stable vs Testing vs Sid — In 20 Seconds
Type: Stable, frozen
Risks: Low
Use: Servers, production, desktop
Routine: apt upgrade
Transition: apt full-upgrade
Type: Frozen rolling
Risks: Moderate
Use: Desktop, testers
Command: apt full-upgrade
Type: Rolling
Risks: High
Use: Developers, experts
Command: apt full-upgrade
🚀 Starter Pack — The 15 Essential Commands
📦 Repository Management
Inspect Repositories
Add, Remove, Modify
🔍 Advanced apt-cache Commands
| Command | Description |
|---|---|
| apt-cache policy [package] | Priorities and available versions |
| apt-cache showpkg <package> | Internal info (reverse dependencies) |
| apt-cache depends <package> | Lists dependencies |
| apt-cache rdepends <package> | Lists packages that depend on it |
| apt-cache stats | Cache statistics |
| apt-cache unmet ⚠️ | Unmet dependencies (deprecated on Debian 13 — prefer apt check) |
| apt-cache madison <package> | Available versions with origin |
📥 Installation / Update / Removal
apt upgrade vs apt full-upgrade vs apt-get dist-upgrade
| Criterion | upgrade | full-upgrade / dist-upgrade |
|---|---|---|
| Updates packages | ✔️ Yes | ✔️ Yes |
| Installs new packages | ❌ No | ✔️ Yes (if needed) |
| Removes packages | ❌ No | ✔️ Yes (if needed) |
| Recommended use | Stable | Testing, Sid, migration |
Advanced Installation
Removal
Locks
Cleanup
🛠️ Maintenance & Diagnostic
Broken Packages
Blocking Processes
Dependencies and Consistency
⚡ Advanced Commands (Expert)
Working with Multiple Distributions
Fine-grained Pinning
Complementary Tools
| Tool | Description | Example Command |
|---|---|---|
| apt-listbugs | Shows bugs before installation | apt-listbugs list apache2 |
| apt-listchanges | Shows recent changes | apt-listchanges --apt |
| apt-rdepends | Recursive dependencies | apt-rdepends vlc |
| aptitude why | Why an auto package is installed | aptitude why python3 |
| nala | Modern optional frontend for APT | apt install nala then nala --help |
🔧 Tools Requiring Installation
Some advanced commands and tools mentioned in this guide are not installed by default on Debian. To use them, simply install the corresponding packages.
| Tool | Role | Installation |
|---|---|---|
| apt-file | Find the package providing a file | sudo apt install apt-file |
| deborphan | List orphaned packages | sudo apt install deborphan |
| needrestart | Check which services need restarting after update | sudo apt install needrestart |
| apt-listbugs | Display bugs before installation | sudo apt install apt-listbugs |
| apt-listchanges | View recent package changes | sudo apt install apt-listchanges |
| aptitude | Interactive package management interface | sudo apt install aptitude |
| nala | Modern APT frontend (improved display) | sudo apt install nala |
⚠️ Dangerous Commands — Red Zone
Some commands can break a system if used incorrectly.
| Command | Danger |
|---|---|
| dpkg --force-depends -i package.deb | Ignores dependencies |
| apt-get -o Dpkg::Options::="--force-confnew" dist-upgrade | Overwrites modified config files |
| dpkg --purge --force-all <package> | Removes even with dependencies |
Best Practices
- Always simulate with --simulate
- Back up configurations
- Use apt-mark hold on critical packages
🏆 Top 12 Advanced APT Commands
🎯 Advanced Practical Cases (GPS format)
🔗 Complete References
Official Debian Documentation
| Source | Content |
|---|---|
| apt | Complete reference for the apt command |
| aptitude | Complete reference for aptitude |
| apt-get | Complete reference for apt-get |
| Aptitude vs. Apt-Get | Comparison and package authentication |
Local Help Pages
📖 Recommended Reads — SafeITExperts
| Source | Content |
|---|---|
| sudo vs su | Complete Guide to Linux Privilege Elevation |
| Desktop Environment Compatibilities | Linux Desktop Environment Compatibilities in 2025 |
| Enable KDE Unstable Plasma on openSUSE | KDE Plasma on openSUSE Tumbleweed |
| Linux, Windows or macOS | 8 Essential Criteria to Choose Your OS |
🎯 Conclusion
APT is a powerful and mature tool that is one of Debian's greatest strengths. Mastering it requires understanding repositories, pinning, and the various commands available.
- Stable → apt upgrade ; Testing/Sid → apt full-upgrade
- Always run apt update before installing
- Use --simulate to preview
- Configure pinning to control priorities
- Clean up with apt autoremove and apt autoclean