Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Understand Linux packages

By updated

Improve this page

A package is a file that holds a piece of software ready to be installed on your Linux system. The package manager takes care of everything: download, installation, updates and removal. This guide explains the essential concepts before moving on to practice.

What you will learn

  • Understand what a package is and why it exists
  • Tell apart the .deb and .rpm formats
  • Know the role of repositories
  • Understand what a dependency is
  • Identify the package manager your distribution uses

What is a package?

On Linux, you do not usually install software by downloading an .exe file from a website. Instead, you use packages, which the system knows how to track.

A package is an archive that holds:

  • the program files (binaries, libraries, configuration),
  • metadata (name, version, author, description),
  • the list of dependencies it needs to work.

What are the two big package families?

Linux mainly uses two package formats, depending on the family of the distribution, and each has its own manager:

FormatExtensionDistributionsManager
Debian.debDebian, Ubuntu, Linux MintAPT (apt)
Red Hat.rpmRHEL, Fedora, Rocky Linux, AlmaLinuxDNF (dnf)

Pacman, Zypper and APK, the other managers

The two big families do not cover the whole landscape. Arch Linux uses Pacman, openSUSE uses Zypper, and Alpine, very common in container images, uses APK. None of them invents a different model: you find packages, repositories and dependencies there too, and only the commands change. Learning apt or dnf therefore pays off even if you meet these distributions one day.

Which family does my distribution use?

The /etc/os-release file names your distribution, and the name tells you the family:

Terminal window
grep -i "ID" /etc/os-release

If you see debian or ubuntu, you are in the .deb family and you use apt.

What is a repository?

A repository is a remote server that hosts thousands of packages. Your package manager knows where to find these servers thanks to its configuration, and it only installs what they publish.

How does a package reach your machine?

The sequence has 4 steps, and it explains most error messages met at installation time: if the repositories are not known, or if their list is out of date, everything stops at the second one.

  1. You ask for a piece of software to be installed (for example curl).
  2. The package manager checks the list of configured repositories.
  3. It downloads the package from the right repository.
  4. It installs the software on your system.

Where are repositories configured?

Each family keeps its repository definitions in its own directory, which you read before adding anything:

Repositories are described in the /etc/apt/sources.list.d/ directory, in the deb822 format. In this format, each repository is a block of "key: value" lines, and two blocks are separated by an empty line. A single block can list several suites (the version of the distribution, such as trixie) and several components (its sections of software, such as main). The file is called ubuntu.sources on Ubuntu 24.04 and debian.sources on Debian 13.

You will still meet the old /etc/apt/sources.list file in old tutorials. On Ubuntu 24.04, it only holds a comment. On Debian 13, debian.sources is the recommended format, but depending on the installation, a sources.list may still exist. So look in both places:

Terminal window
cat /etc/apt/sources.list.d/*.sources
cat /etc/apt/sources.list

If one of these commands reports that the file does not exist, or shows only a comment, your repositories are in the other one. The guide Manage packages with APT covers this format and how to add a repository.

Not all repositories are equal. Your distribution provides official repositories, whose software is tested and maintained consistently with the rest of the system. Adding a third-party repository gives access to software missing from the catalogue, but carries two risks: compatibility, when a library there is newer than the system's, and security, since these packages are installed with administrator rights. Stay on the official repositories whenever you can.

What is a dependency?

A dependency is a piece of software or a library that a package needs in order to work.

For example, a text editor may need a graphical library to draw its windows. If that library is not installed, the software will not work.

What the manager does for you

On installation, the manager downloads and installs every missing dependency: you do not have to keep the list yourself.

On removal, the behavior depends on the family. On Debian and Ubuntu, apt remove leaves the dependencies that are no longer needed and apt autoremove offers to remove them. On AlmaLinux and RHEL, dnf remove removes them itself (the clean_requirements_on_remove setting, enabled by default), except for a dependency that you installed by hand.

A concrete example

When you install nginx (a web server), the manager also automatically installs the other packages nginx needs:

Terminal window
sudo apt install nginx
Output on Ubuntu 24.04 (excerpt)
The following additional packages will be installed:
nginx-common

APT installs nginx and its dependency nginx-common in a single command. On a minimal Debian 13, the same command adds 17: the number depends on what the system already holds.

What is the role of the package manager?

The package manager is the central tool to maintain the software on your system. It does much more than install: it ensures the consistency of the whole system, and every change goes through its inventory.

TaskWithout a package managerWith a package manager
Install softwareDownload, compile, copy by handOne command
UpdateCheck the websites one by oneOne command updates everything
Remove cleanlyLook for every file by handComplete automatic removal
Handle dependenciesFind and install them yourselfAutomatic resolution
SecurityNo checkGPG signatures checked

This table explains why manual installation is a problem. Downloading a .tar.gz from a website bypasses the manager: the software shows up in no inventory, it will get no security updates, its dependencies will not be tracked, and removing it will leave you hunting for its files one by one. Always prefer the official package when it exists.

Which apt and dnf commands should you remember?

Here are the essential commands you will use in the next guides, side by side for the two families, so that you can move from one to the other:

ActionAPT (Debian/Ubuntu)DNF (RHEL/Fedora)
Refresh the package listsudo apt updateno dedicated command
Install a packagesudo apt install namesudo dnf install name
Remove a packagesudo apt remove namesudo dnf remove name
Search for a packageapt search keyworddnf search keyword
Update the whole systemsudo apt upgradesudo dnf upgrade

There is no equivalent of apt update on the DNF side: DNF refreshes its metadata when it has expired (48 hours by default), and dnf check-update lists the updates, with the --refresh option forcing the refresh.

You will often meet apt-get in older tutorials, and the command remains perfectly valid. apt is its modern form, designed for interactive use: more readable output, progress bar, clearer summary. Both do fundamentally the same thing, and apt-get keeps an edge in scripts, where its output does not change from one version to the next.

Key points

  • A package holds a piece of software, its metadata and its dependencies.
  • The two main formats are .deb (Debian/Ubuntu → apt) and .rpm (RHEL/Fedora → dnf).
  • A repository is a server that hosts the available packages.
  • A dependency is a piece of software required by another, handled automatically.
  • The package manager installs, updates, removes and secures your software in a single command.
  • Always prefer official packages to manual installations.

Knowledge check

Check that the essentials of this guide stuck. The questions cover only what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

6 questions
6 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer