Ubuntu Package Managers Overview

August 22, 2024

Introduction

A package manager is an essential tool in any Linux system. It is responsible for installing, updating, and managing software packages efficiently. Like other Linux distributions, Ubuntu relies on package managers to streamline software management so users can easily access and maintain applications and dependencies.

This article provides an overview of different package managers available for Ubuntu and outlines the basics for using them.

Ubuntu package managers overview.

What Is a Package Manager?

A package manager is a tool that automates software installation, updating, configuration, and removal. It retrieves packages from repositories, resolves dependencies, and ensures a proper installation of the necessary software components for it to function correctly.

By automating the process, package managers eliminate the need for manual installation, making software management more straightforward and reducing the risk of errors.

Using a package manager simplifies software management across the system, speeds up installations and updates, and facilitates the removal of unwanted apps. The tool is a cornerstone of efficient system administration, especially when stability and consistency are critical.

Note: While Linux distributions use package managers like apt, yum, or dnf, Windows uses package managers like Chocolatey and Winget. On macOS, the most widely used package manager is Homebrew.

Ubuntu Package Managers

Ubuntu supports multiple package managers, which provide users with flexibility and options that suit different scenarios. Some package managers provide advanced command-line tools, while others feature simple graphical interfaces.

The sections below provide an overview of Ubuntu's most prominent package managers.

apt

apt (Advanced Package Tool) is the default package manager for Ubuntu, and it is designed to manage .deb packages. It simplifies software installation, upgrades, and removal by automating dependency resolution and package management.

The tool is widely used for system maintenance, ensuring that all required packages are installed and updated with minimal user intervention.

dpkg

dpkg is the lower-level package manager that serves as the backend for apt. It manages .deb packages directly, allowing users to install, remove, and query individual packages.

However, unlike apt, dpkg does not automatically resolve dependencies, which makes some installations more complex.

Snap

Snap is a package manager that offers a modern approach to software distribution on Ubuntu. It enables the installation of containerized packages called snaps, which include all the necessary dependencies and can run independently of the system's libraries.

Snap is particularly useful for distributing apps that require specific versions of libraries or need to run on multiple Linux distributions.

apt vs. dpkg vs. Snap

apt, dpkg, and Snap provide users with a versatile toolkit for managing software, from traditional system packages to modern, containerized applications. Each tool serves a distinct purpose, catering to different needs within the ecosystem.

The table below provides a quick overview of apt, dpkg, and Snap, highlighting their roles, features, and use cases in Ubuntu:

Featureapt (Advanced Package Tool)dpkgSnap
Primary FunctionHigh-level package management, automates dependency resolution.Low-level package management, no automatic dependency handling.Containerized package management.
Package Format.deb.deb.snap
Dependency HandlingAutomatic.Manual.Dependencies included in the package.
Default for UbuntuYes.No (backend for apt).No.
Software ScopeSystem-wide software packages.System-wide software packages.Standalone, cross-distribution applications.
SandboxingNo.No.Yes.
Installation MethodCommand-line or GUI (e.g., Synaptic).Command-line.Command-line or Snap Store.
Repository SupportYes (with PPA support).No.Yes (Snap Store).
System CompatibilityDebian-based systems.Debian-based systems.Cross-distribution (all major Linux distros).
Use CasesGeneral software management.Advanced users, specific package installation.Installing isolated apps, avoiding dependency conflicts.

Ubuntu Package Management

Package management involves software installation, configuration, update, and removal. The process handles dependencies and ensures software integrity and compatibility across the operating system.

The sections below provide hands-on examples of Ubuntu package management with apt, dpkg, and Snap.

List Installed Packages

Listing installed packages outputs a list of all the applications you have installed on the system. The process differs for each package manager, as explained in the sections below.

List Packages with apt

apt provides a straightforward way to list all installed packages:

apt list --installed

The command displays a list of all packages currently installed on the system, along with their versions and status. The output includes the package name, version, and a status indicator showing whether the package is installed, upgradable, or held back.

For example:

Listing installed packages with apt.

List Packages with dpkg

dpkg directly interacts with the package database to list installed packages:

dpkg --list
Listing installed packages with dpkg.

The detailed output includes the package name, desired action, current status, and description.

You can combine this command with grep to filter the output or search for specific packages. The syntax is:

dpkg --list | grep [package_name]

List Packages with Snap

Use the command below to list the installed .snap packages:

snap list
Listing installed snap packages in Ubuntu.

The output includes the package name, version, developer (publisher), and the tracking (channel) used for updates. This command is specific to .snap packages and does not list .deb packages managed by apt or dpkg.

Search Packages

Searching for packages involves querying available repositories to find software packages by name or description. Each package manager has its own way of searching for packages.

Search Packages with apt

apt allows you to search for packages in the available repositories using the syntax below:

apt search [package_name]

For example:

Searching for a package with apt.

The command returns a list of matching packages, including their names, versions, and brief descriptions.

Search Packages with dpkg

dpkg does not directly support searching for packages in remote repositories as it is designed to manage installed packages locally. apt is the recommended tool for repository searches.

Search Packages with Snap

Snap allows you to search for packages in the Snap Store, or via the command line using the syntax below:

snap find [package_name]
Searching for packages with the Snap package manager.

The command searches the Snap Store for packages by name or description. The results include package names, versions, publishers, and brief descriptions, covering all snap packages available in the store.

Install Packages

Installing packages involves downloading and setting up software from repositories onto your system.

Install Packages with apt

apt is the default tool for installing packages from the Ubuntu repositories. The syntax is:

sudo apt install [package_name]

For example:

Installing a package with apt.

The command installs the specified package from the repositories configured in your system. It automatically handles dependencies, ensuring that all required packages are installed alongside the requested package. It also verifies the integrity of packages before installation.

Install Packages with dpkg

dpkg is used to install .deb packages you have previously downloaded but cannot install directly from the repositories. The syntax for installing a package with dpkg is:

sudo dpkg -i [path_to_package]
Installing a package with dpkg.

Make sure to specify the full path to the package and the correct package name.

Install Packages with Snap

Snap installs packages from the Snap Store. If you are using the terminal, the syntax for installing a package is:

sudo snap install [package_name]

For example:

Installing a package with the Snap package manager.

Snap packages are self-contained, meaning they include all necessary dependencies, which simplifies the installation process. Snaps are also automatically updated to the latest version when available.

Update Packages

Updating packages involves downloading and applying the latest updates to installed software from the repositories.

Update Packages with apt

apt is the primary tool for updating packages from Ubuntu repositories. Run the commands below to update the packages with apt:

sudo apt update
sudo apt upgrade
  • The sudo apt update command refreshes the local package index, ensuring your system gets the list of the latest available program versions.
  • The sudo apt upgrade command installs updates for all upgradable packages. apt manages dependencies and ensures that updates are applied smoothly across the system.

Update Packages with dpkg

dpkg does not support updating packages directly from the repositories. Instead, you must download the new program version to your system and provide the file path to the dpkg command.

The syntax is:

sudo dpkg -i [path_to_package.deb]

Update Packages with Snap

Snap updates packages from the Snap Store. The command is:

sudo snap refresh

The tool checks for updates and applies them to all installed snap packages. Snap packages are updated independently of the system, ensuring that each application is always up to date with the latest version available in the Snap Store.

Uninstall Packages

Uninstalling packages involves removing software from your system along with any associated files. This section shows how to use each package manager to remove packages.

Uninstall Packages with apt

apt is commonly used to remove packages and all the associated dependencies from a Ubuntu system. The syntax for uninstalling a package with apt is:

sudo apt remove [package_name]

The command removes the specified package but leaves its configuration files intact. If you want to remove the package and its configuration files, use the following syntax:

sudo apt purge [package_name]
Uninstalling a package with apt.

apt automatically removes dependencies if any other installed package no longer requires them.

Uninstall Packages with dpkg

dpkg can also be used to uninstall packages installed from .deb files. The syntax is:

sudo dpkg -r [package_name]

The command removes the specified package but leaves its configuration files on the system. If you want to remove the package along with its configuration files, use the syntax below:

sudo dpkg --purge [package_name]

Unlike apt, dpkg does not automatically manage dependencies, so you may need to manually remove any orphaned packages.

Uninstall Packages with Snap

Snap uninstalls .snap packages from the system. The syntax is:

sudo snap remove [package_name]
Removing a Snap package from Ubuntu.

The command removes the specified .snap package from the system, including all associated files. Snap automatically handles the cleanup and ensures that no remnants of the package are left behind.

Conclusion

This article provided an overview of the most common package managers used in Ubuntu and basic commands for using them. Package managers are essential tools in Linux as they automate package management and reduce the risk of errors during app installation and configuration.

Next, learn the difference between Flatpak, Snap, and AppImage, three distribution-independent package formats, or dive into our Snap vs. apt comparison article to compare the two package managers in detail.

Was this article helpful?
YesNo
Bosko Marijan
Having worked as an educator and content writer, combined with his lifelong passion for all things high-tech, Bosko strives to simplify intricate concepts and make them user-friendly. That has led him to technical writing at PhoenixNAP, where he continues his mission of spreading knowledge.
Next you should read
How to Uninstall or Remove Packages in Ubuntu
May 23, 2024

This guide will walk you through several methods for removing old or unwanted software from an Ubuntu system.
Read more
How to Install RPM Packages on Ubuntu
March 28, 2024

RPM is a package format used by Red Hat based derivatives like CentOS, RHEL or Fedora. In this tutorial, learn how to install .rpm packages on Ubuntu.
Read more
How to Install Deb Files (Packages) on Ubuntu
May 25, 2023

This article shows you several different ways of installing deb packages on a Ubuntu system.
Read more
How to Fix Broken Packages in Ubuntu
October 14, 2021

This article will show you how to troubleshoot and fix broken packages on Ubuntu using the available APT and DPKG tools.
Read more