linuxfundamentalspart3 linuxfundamentals

On Linux distributions, packages are archives used to share:

  • πŸ“š Libraries (.a and .so files)
  • ✍️ Documentation (packagename-doc)
  • πŸ“„ Headers (packagename-dev)
  • πŸ•ΉοΈ Applications (binaries)
  • ...

Each operating system has a package management system to install and remove packages. We usually don't directly interact with it, and we use a package management tool instead. They allow us to download packages from package repositories and update them too.

In a nutshell, we often see these combinations:

Package System πŸ–₯️ Package Tool πŸ› οΈ Package format πŸ—οΈ
dpkg apt or aptitude .deb
rpm dnf or yum ☠️ .rpm
pacman pacman
  • dpkg is mainly used by Debian-like distributions.
  • rpm is mainly used by Fedora and Red Hat.
  • pacman is mainly used by Arch Linux.

Package Systems And Tools

Usage 🐚: apt is the default package manager on well-known Linux distros such as Debian/Ubuntu.

Example πŸ”₯:

Install, Update, Remove a package

$ sudo apt install aptitude
$ sudo apt update aptitude
$ sudo apt upgrade aptitude
$ sudo apt remove aptitude

Download updates for/upgrade all packages

$ sudo apt update
$ sudo apt upgrade

Update the OS πŸ§ͺ

$ sudo apt dist-upgrade

Remove unused dependencies

$ sudo apt autoremove
$ sudo apt auto-remove

When installing packages, you are prompted Do you want to continue? [Y/n] (you need to enter Y). You can skip this, using -y.

$ sudo apt install -y aptitude

Configuration files are stored in /etc/apt/:

$ cat /etc/apt/sources.list # repositories
$ ls /etc/apt/apt.conf.d/   # proxy conf etc.

List installed packages:

$ apt list --installed

Usage 🐚: aptitude (which has to be installed) is the same as apt, but there is a graphical interface.

Example πŸ”₯:

$ sudo aptitude # press 'q' to quit

Or, you can use it like apt:

$ sudo aptitude install nano

Usage 🐚: apt uses the lower-level package manager dpkg to install packages. Some developers may directly interact with it.

Example πŸ”₯:

$ sudo dpkg -i xxx.deb

Usage 🐚: snap packages are a modern way to share applications. They contain all dependencies, and support automatic updates. Some cons are their larger size and sometimes there are performance issues.

πŸ‘‰ Find Snap packages here.

Example πŸ”₯:

$ sudo apt update
$ sudo apt install snapd
$ sudo snap install core
$ sudo snap refresh core
$ sudo snap install --classic xxx

Usage 🐚: available on Debian-based distributions. Allow us to switch between multiple versions of the same program.

πŸ›» c++, cc, nc, php, java...

Example πŸ”₯:

$ sudo update-alternatives --config php


To reduce the time it takes to download packages, multiple mirrors of package repositories are set up, and users should use the nearest ones. A mirror is basically a copy of a package repository.

It could be hosted locally.


Apt-mirror is a tool used on Linux to create a mirror.

$ sudo apt-get install apt-mirror
$ sudo cat /etc/apt/mirror.list
set base_path    /path/to/mirror
set run_postmirror 0

deb buster main
$ sudo apt-mirror /etc/apt/mirror.list

It will create a folder mirror inside /path/to/mirror with:

  • dists/<codename>/<repository>: contains the metadata
  • pool/<repository>: contains the downloaded packages


Aptly is a powerful tool created to simplify the process of creating and maintaining package repositories. It can be used to create mirrors.

$ apt-key adv --keyserver --recv-keys A0546A43624A8331
$ sudo apt-get install aptly
$ sudo cat ~/.aptly.conf     # aptly config show
    "rootDir": "/path/to/mirror",
    "downloadConcurrency": 20,
    "architectures": ["amd64"]
$ [handle gpg problems]
$ aptly mirror create node20 nodistro main
$ aptly mirror update node20

πŸ‘» To-do πŸ‘»

Stuff that I found, but never read/used yet.

$ apt-file
$ apt-file update
$ apt autoclean
$ wget -qO - xxx.gpg | apt-key add -
  • APT store information about packages in a local database for offline use.
$ apt-cache search <name>
$ apt-cache show <package_name>