GICT knowledge base
A Beginner’s Guide to Linux Package Managers
Published
When you first start using Linux, one of the things that surprises people coming from Windows or macOS is how software installation works. There is no hunting for a download link, no running an installer, no clicking through a setup wizard. You open a terminal, type one command, and the software is installed – along with everything it needs to run.
That is a package manager doing its job. It handles downloading, installing, updating, and removing software in a way that keeps your system clean and consistent. Once you understand how it works, managing software on Linux becomes faster and more reliable than on any other operating system.
This guide covers what package managers are, how they work, and the commands you will actually use day to day.
Prerequisites
- You have a Linux machine or server running.
- You are comfortable opening a terminal and typing commands.
- No prior experience with package managers is needed.
What a Package Manager Is
A package is a bundle containing everything needed to install a piece of software – the program files, configuration templates, documentation, and metadata describing what other software it depends on.
A package manager is the tool that handles those packages. It knows where to find them, how to download them, how to install them without breaking anything else, and how to remove them cleanly when you are done.
The alternative – downloading software manually from websites, compiling from source, handling dependencies yourself – is slow and messy. Package managers exist because that process does not scale. Once you are managing a server with dozens of installed packages, doing it by hand becomes unsustainable.
Package Repositories
Package managers do not download software randomly from the internet. They pull from repositories – curated collections of packages maintained by your Linux distribution or trusted third parties.
When you install something, the package manager checks the repository, finds the right version, downloads it along with any dependencies, and installs everything together. The repository also tells the package manager what updates are available, which is how apt upgrade or yum update knows what to fetch.
Repositories are configured in text files on your system. Most of the time you never need to touch them – the defaults that come with your distribution cover the vast majority of software. Occasionally you will add a third-party repository to get software that is not in the official ones.
APT – Debian and Ubuntu
APT is the package manager used on Debian, Ubuntu, and distributions based on them. It is what you will use on most cloud servers running Ubuntu, which makes it the most commonly encountered package manager in server environments.
Updating the Package List
Before installing anything, update the local list of available packages. This does not install anything – it just refreshes what APT knows is available in the repositories.
$ sudo apt update
Run this before any install session. If you skip it, you might install an outdated version of something because APT is working from a stale list.
Installing a Package
$ sudo apt install nginx
APT resolves dependencies automatically. If Nginx needs a library that is not installed yet, APT finds it, downloads it, and installs it alongside Nginx without you doing anything extra.
To install multiple packages at once:
$ sudo apt install nginx php-fpm mysql-server
Upgrading Installed Packages
$ sudo apt upgrade
This installs newer versions of everything currently installed, based on what is available in the repositories. Run apt update first so APT knows what the latest versions are.
For a more aggressive upgrade that also handles packages that need other packages removed or added:
$ sudo apt full-upgrade
Removing a Package
$ sudo apt remove nginx
This removes the package but leaves its configuration files behind. If you might reinstall it later and want to keep your settings, this is the right command.
To remove the package and its configuration files:
$ sudo apt purge nginx
Removing Unused Dependencies
When you install a package that pulls in dependencies and then remove that package, the dependencies often stay behind. They are not needed anymore but APT does not remove them automatically.
$ sudo apt autoremove
Run this periodically to clean up packages that nothing depends on anymore.
Searching for a Package
$ apt search nginx
Returns a list of packages with “nginx” in the name or description. Useful when you know roughly what you want but not the exact package name.
To see detailed information about a specific package before installing it:
$ apt show nginx
YUM and DNF – Red Hat, CentOS, Fedora
YUM was the standard package manager for Red Hat-based distributions for many years. DNF replaced it on Fedora first and then on newer versions of RHEL and CentOS Stream. DNF is largely compatible with YUM commands – if you know one, you mostly know the other.
Installing a Package
$ sudo dnf install httpd
Note that package names sometimes differ between distributions. Apache is nginx on both Debian and Red Hat systems but the Apache HTTP server is apache2 on Debian and httpd on Red Hat.
Updating Packages
$ sudo dnf update
Unlike APT, DNF does not require a separate update step to refresh the package list first – it handles that automatically.
Removing a Package
$ sudo dnf remove httpd
Searching for a Package
$ dnf search httpd
Pacman – Arch Linux
Arch Linux uses Pacman, which has a different syntax from APT and DNF but follows the same concepts.
Installing a Package
$ sudo pacman -S nginx
Updating the System
$ sudo pacman -Syu
This syncs the package database and upgrades all installed packages in one command.
Removing a Package
$ sudo pacman -R nginx
To remove a package and any dependencies that nothing else uses:
$ sudo pacman -Rs nginx
Snap and Flatpak – Universal Package Formats
The package managers above are distribution-specific. A package built for Ubuntu does not install directly on Fedora. Snap and Flatpak are attempts to solve this by creating a universal package format that works across distributions.
Snap
Snap packages bundle the application and all its dependencies into one self-contained unit. They update automatically in the background. Canonical, the company behind Ubuntu, develops Snap.
$ sudo snap install code
Snap packages tend to be larger than traditional packages because they carry their own dependencies. They also start up slightly slower. For desktop applications where compatibility across distributions matters, Snap is practical. For server software, traditional packages are usually the better choice.
Flatpak
Flatpak follows a similar approach to Snap but is developed independently and has broader support across distributions. It is more common on desktop Linux systems than on servers.
Understanding Dependencies
Dependencies are one of the things that make package managers valuable. Most software relies on libraries and other programs to function. Tracking and installing all of those manually would be tedious and error-prone.
When you install a package, the package manager reads its dependency list and installs everything on it. If two packages both need the same library, the package manager installs one copy and shares it between them. When you remove a package, the package manager knows what it brought in and can clean it up.
This dependency resolution is invisible when it works, which is most of the time. You see it clearly when something goes wrong – a package that cannot be installed because a dependency conflicts with something already installed. Most of the time, the package manager either resolves these conflicts automatically or gives you a clear explanation of what the conflict is.
Useful Habits
- Always run
apt updatebefore installing on Ubuntu. The package list goes stale if you have not updated in a while. Skipping this step means you might install an outdated version or miss a package that was added recently. - Use
autoremoveregularly. Installed dependencies accumulate over time. Runningapt autoremoveordnf autoremoveperiodically keeps your system tidy. - Check what a package includes before installing.
apt showanddnf infogive you a description, version, and dependency list before anything is installed. Worth a quick look when you are installing something unfamiliar. - Keep the system updated on servers. Outdated packages, especially security-sensitive ones like OpenSSL and the kernel, are a common attack vector. Set up unattended upgrades for security updates if you are not monitoring the server daily.
Conclusion
Package managers are one of the things that make Linux genuinely pleasant to work with once you know how they work. Software installs in seconds. Updates apply consistently across everything on the system. Removing something cleans up after itself.
The commands you will use most are probably ten at most – update, install, upgrade, remove, and search. Everything else is a variation on those. Pick up the basics for whichever package manager your distribution uses and the rest comes naturally from there.
Related guides
How to Set Up zram on a Small VPS
Configure zram on Ubuntu with kernel and swap checks. Understand compressed memory limits, monitor real use and avoid unsafe swap-file changes.
LinuxHow to Find Services That Need a Restart After Updates with needrestart
Find services using outdated libraries with needrestart on Ubuntu. Read restart reports, review automatic restart policy and plan maintenance safely.
LinuxHow to Limit a Linux Service’s Memory with systemd
Limit a Linux service with systemd MemoryHigh, MemoryMax and swap controls. Check cgroup support, diagnose pressure and remove only your own policy.
LinuxHow to Protect SSH with CrowdSec on Ubuntu
Protect SSH with CrowdSec on Ubuntu. Connect log detection to firewall enforcement and test temporary blocking without losing administrator access.
