Package Management

Updated: 2020-06-29

What is a Package Manager

From wikipedia:

A package manager or package management system is a collection of software tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer's operating system in a consistent manner.

dpkg (Debian Package Manager)

Install a local .deb package in Ubuntu:

$ dpkg -i filename.deb

List pakcages:

$ dpkg -l

Check all installed packages

$ dpkg --get-selections
$ dpkg --get-selections | grep mongo

dpkg is a backend-ish tool, usually we do not need to use it directly. Check other options in $ man dpkg.

Apt

apt can be considered a front-end to dpkg.

apt is a simplified command that combines the most commonly used command options from apt-get and apt-cache.

Commands

$ sudo apt install <package>
$ sudo apt install <package>=<version>    # Install a specific version
$ sudo apt search <package>
$ sudo apt show <package>
$ sudo apt update
$ sudo apt list --upgradable
$ sudo apt list --installed
$ sudo apt upgrade
$ apt-cache stats: get stats of the packages
$ apt-cache pkgnames | grep docker

apt update vs apt upgrade vs apt dist-upgrade

apt update will only check the latest versions of the packages, without actually downloading package updates; apt upgrade will do the actual upgrading; while apt dist-upgrade is for upgrading the OS itself.

Where do the packages come from?

They come from "repositories" listed in

  • /etc/apt/sources.list
  • /etc/apt/sources.list.d/

Snap

Snaps now work natively on Arch, Debian, Fedora, and different flavors of Ubuntu.

Why Snap

"With snap packages, applications are installed in their own container, and all the third-party applications are installed with them so there are no version conflicts." This allows users to update and roll back applications without causing problems to the rest of their operating system. It also comes with security benefits because applications are more isolated from each other and from core parts of the OS than they normally would be.

How to Create Snap Package

http://snapcraft.io/