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:
| Format | Extension | Distributions | Manager |
|---|---|---|---|
| Debian | .deb | Debian, Ubuntu, Linux Mint | APT (apt) |
| Red Hat | .rpm | RHEL, Fedora, Rocky Linux, AlmaLinux | DNF (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:
grep -i "ID" /etc/os-releaseIf you see debian or ubuntu, you are in the .deb family and
you use apt.
grep -i "ID" /etc/os-releaseIf you see rhel, fedora, rocky or almalinux, you are in the
.rpm family and you use dnf.
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.
- You ask for a piece of software to be installed (for example
curl). - The package manager checks the list of configured repositories.
- It downloads the package from the right repository.
- 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:
cat /etc/apt/sources.list.d/*.sourcescat /etc/apt/sources.listIf 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.
Repositories are defined in the .repo files of the
/etc/yum.repos.d/ directory.
ls /etc/yum.repos.d/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:
sudo apt install nginxThe following additional packages will be installed: nginx-commonAPT 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.
sudo dnf install nginxInstalling: nginx x86_64 2:1.26.3-6.el10_2.7 appstreamInstalling dependencies: almalinux-logos-httpd noarch 100.4-1.el10_2 appstream nginx-core x86_64 2:1.26.3-6.el10_2.7 appstream nginx-filesystem noarch 2:1.26.3-6.el10_2.7 appstreamDNF installs nginx and its dependencies automatically.
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.
| Task | Without a package manager | With a package manager |
|---|---|---|
| Install software | Download, compile, copy by hand | One command |
| Update | Check the websites one by one | One command updates everything |
| Remove cleanly | Look for every file by hand | Complete automatic removal |
| Handle dependencies | Find and install them yourself | Automatic resolution |
| Security | No check | GPG 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:
| Action | APT (Debian/Ubuntu) | DNF (RHEL/Fedora) |
|---|---|---|
| Refresh the package list | sudo apt update | no dedicated command |
| Install a package | sudo apt install name | sudo dnf install name |
| Remove a package | sudo apt remove name | sudo dnf remove name |
| Search for a package | apt search keyword | dnf search keyword |
| Update the whole system | sudo apt upgrade | sudo 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
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
Review
(0/0)Result saved on this device. It will be sent to your account at the next sync. Sync now
Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: Install and remove software on Linux
A new full quiz with random questions
Work again only on the questions you missed