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 :
Share

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

Or Copy Link

CONTENTS
Scroll to Top