🧰 Linux/Unix: Debian-Based Package Management – apt, dpkg, snap Explained with Examples

🧲 Introduction – Why Learn Debian-Based Package Tools?

If you’re using Ubuntu, Linux Mint, Kali, or any Debian-based distribution, then apt, dpkg, and snap are your go-to tools for installing, removing, and managing software. These package managers help you handle dependencies, updates, and even sandboxed applications from the terminal.

🎯 In this guide, you’ll learn:

  • How to install, remove, and update packages using apt and dpkg
  • How snap differs and when to use it
  • Real command examples and outputs for each tool

πŸ“¦ 1. apt – Advanced Package Tool (User-Friendly)

βœ… What is apt?

apt is the front-end tool for Debian package management that automatically handles dependencies, repositories, and updates. It is interactive and scriptable.

πŸ› οΈ Syntax:

sudo apt [command] [package]

πŸ”Ή Common apt Commands:

CommandDescription
updateRefresh package list
upgradeUpgrade all installed packages
installInstall a new package
removeRemove a package (keep config)
purgeRemove a package and its config files
searchSearch for packages
showShow package details

πŸ§ͺ Examples:

βœ… Install a package:

sudo apt install vim

βœ… Update repositories:

sudo apt update

βœ… Upgrade all packages:

sudo apt upgrade

βœ… Remove a package:

sudo apt remove firefox

πŸ“€ Output:

Reading package lists... Done
Building dependency tree... Done
The following packages will be REMOVED:
  firefox

πŸ“¦ 2. dpkg – Debian Package Manager (Low-Level)

βœ… What is dpkg?

dpkg is the low-level backend used by apt. It directly installs .deb files and does not handle dependencies automatically.

πŸ› οΈ Syntax:

sudo dpkg [option] [package.deb]

πŸ”Ή Common dpkg Commands:

CommandDescription
-iInstall a .deb package
-rRemove an installed package
-PPurge the package completely
-lList all installed packages
-sShow info about installed package
-LList files installed by a package

πŸ§ͺ Examples:

βœ… Install a local .deb package:

sudo dpkg -i google-chrome.deb

πŸ“€ Output:

Unpacking google-chrome ...
Setting up google-chrome ...

βœ… Check if a package is installed:

dpkg -l | grep curl

🧠 If dependencies are missing:

sudo apt --fix-broken install

πŸ“¦ 3. snap – Universal Linux Package Manager

βœ… What is snap?

snap packages are self-contained and sandboxed, designed to work across all Linux distros. Managed via the snap command, it installs apps with automatic updates and rollback.

πŸ“¦ Install Snap on Debian-based distros:

sudo apt install snapd

πŸ› οΈ Syntax:

sudo snap [command] [package]

πŸ”Ή Common snap Commands:

CommandDescription
installInstall a snap package
removeRemove a snap package
listList installed snaps
infoGet details about a snap package
refreshUpdate installed snaps
revertRollback to previous version

πŸ§ͺ Examples:

βœ… Install a snap:

sudo snap install code --classic

πŸ“€ Output:

code 1.86.0 from Microsoftβœ“ installed

βœ… List installed snaps:

snap list

βœ… Remove a snap:

sudo snap remove code

βš™οΈ Tool Comparison: apt vs dpkg vs snap

Featureaptdpkgsnap
Handles dependenciesβœ…βŒβœ…
Works offline❌ (needs repo)βœ…βœ… (after initial download)
GUI appsβœ…βŒβœ… (sandboxed)
Auto-updatesβŒβŒβœ…
Rollback supportβŒβŒβœ…

πŸ“Œ Summary – Recap & Next Steps

Debian-based systems give you versatile package toolsβ€”apt for daily management, dpkg for direct .deb installs, and snap for universal apps with rollback and confinement.

πŸ” Key Takeaways:

  • Use apt for most tasksβ€”install, remove, update, and upgrade packages.
  • Use dpkg to manually install .deb files.
  • Use snap to install modern sandboxed applications with auto-updates.

❓ FAQs

❓ What’s the difference between apt and dpkg?
βœ… apt resolves dependencies from repos. dpkg installs local .deb files without resolving dependencies.

❓ How do I fix broken packages installed by dpkg?
βœ… Run:

sudo apt --fix-broken install

❓ Are snap packages safe to use?
βœ… Yes. They’re confined (sandboxed) and receive automatic security updates.

❓ Can I install GUI apps using snap?
βœ… Absolutely. Examples: snap install vlc, snap install code.

❓ How do I completely remove a package and its config using apt?
βœ… Use:

sudo apt purge <package>

Share Now :

Leave a Reply

Your email address will not be published. Required fields are marked *

Share

πŸ”΅ Linux/Unix: Debian-based (apt, dpkg, snap)

Or Copy Link

CONTENTS
Scroll to Top