best cloud hosting companies

Mar 07, 2025

26 min read

Package Management in Linux: How to Use APT and DNF Commands

Written by

Abdelhadi Dyouri
Ever stared at the terminal, wondering if your next command will install a cool software package on your system, or break it completely? Linux package managers like APT and DNF might seem daunting, but they're actually very easy to master once you understand how they work. The core concepts of package management are surprisingly simple, and they are guaranteed to make you 10X better at working with Linux. In this guide, I'll share the basics that helped me go from randomly copying commands from Stack Overflow to confidently managing any Linux system. I'll show you exactly how to master APT and DNF, the two most important package managers. No fluff, no theory overload, just practical easy-to-understand knowledge that will save you hours of debugging and prevent those dreaded system failures. Let's make package management click for you. Linux Package Management

Prerequisites for APT and DNF Package Managers

To make the most out of this Linux package management guide, you’ll need a VPS:
  • To learn how to use the APT package manager, you’ll need a VPS running Ubuntu or Debian.
  • To learn how to use the DNF package manager, you’ll need a VPS running Rocky Linux, Fedora, CentOS Stream, or AlmaLinux.
  • A non-root user with sudo privileges. Check out our How to access your server using SSH guide to learn how to access your server and create a sudo user.
  • Basic Linux command line knowledge.
If you haven't noticed, we offer the best priced, most reliable Linux VPS servers. Take a look at our deals and prepare for your mind to be blown 🤯.

What is a Package Manager in Linux?

Package managers are used to distribute Linux software in pre-compiled bundles called packages. Think of them as app stores for your Linux system. They handle all the heavy lifting, downloading, installing, updating, and removing software. To manage packages, most Linux distributions make use of either APT (Advanced Package Tool) or DNF (Dandified YUM). These tools make sure you get the right versions of software and keep your system running smoothly.

What Two Linux Distributions Utilize the Debian Package Manager by Default?

Ubuntu and Debian are the two most popular distributions that use APT. Ubuntu is perfect for beginners and powers millions of servers worldwide, while Debian is known for its rock-solid stability. Both share the same powerful package management system that makes software installation a breeze.

Linux Distributions That Utilize the DNF Package Manager by Default

Fedora, Rocky Linux, and AlmaLinux are the main distributions that use DNF. Fedora leads the pack with cutting-edge features, while Rocky Linux and AlmaLinux are built for enterprise stability. These distributions switched from YUM to DNF for better performance and dependency handling.

APT vs DNF: What Is the Best Linux Package Manager?

Both APT and DNF are excellent at their jobs. There's no clear winner! APT has been around longer and has a larger package repository, while DNF offers more modern features like better dependency resolution and faster performance. Your choice really depends on which Linux distribution you're using. Now that you understand the basics of package managers, let's dive into the practical commands that will make you a Linux pro. I'll show you exactly how to find and install any software you need with our Linux Package Manager Cheat Sheet below!

Linux Package Manager Cheat Sheet

Here's your quick reference guide for both APT and DNF commands. I've paired them side by side so you can easily spot the similarities:
Action APT Command DNF Command
Update package list apt update dnf check-update
Upgrade all packages apt upgrade dnf upgrade
Install a package apt install package dnf install package
Remove a package apt remove package dnf remove package
Search for a package apt search keyword dnf search keyword
Show package info apt show package dnf info package
Clean package cache apt clean dnf clean all
List installed packages apt list --installed dnf list installed
Pro Tip: Add -y to any install or remove command to skip the confirmation prompt. For example, to install Nginx: apt install -y nginx or dnf install -y nginx. Now that you've got this handy cheat sheet, let's dive deeper into APT commands. I'll show you some cool tricks that aren't obvious from the basic syntax, like installing specific versions and managing dependencies. These will save you hours of troubleshooting down the road.

How to Use APT Commands in Linux

APT (Advanced Package Tool) is Linux's package management system. Here are the essential APT commands in Linux:
  • Update package list: apt update
  • Install software: apt install package
  • Upgrade installed packages: apt upgrade
  • Remove software: apt remove package
  • Find packages: apt search keyword
Always run apt update before installing or upgrading packages to ensure you get the latest versions. Let's dive deeper in the next section and start with the most important task: installing packages...

Note: Do You Want to Practice These Commands Risk-Free?

Want to master APT without worrying about breaking your system? The best way to do that is to get a fresh Ubuntu or Debian VPS where you can experiment freely. Try commands, test configurations, and if something breaks, just reset and start fresh in seconds. Get started with a VPS for just $11/month. With instant setup, and 14-day money-back guarantee. Launch your sandbox →

How to Install a Linux Package Using APT

Installing packages with APT is super straightforward. First, refresh your package list:
sudo apt update
linux package updates using apt Then install your software with a simple command:
sudo apt install package-name
APT install Want to install multiple packages? Just list them with spaces:
sudo apt install nginx php mysql-server
Now you have your packages installed. Great! But wait, what if your app needs a specific version to work properly? Let me show you a neat trick in the next section...

How to Install a Specific Version for a Package Using APT

Sometimes you need an exact version, maybe for compatibility or stability reasons. First, check available versions:
Continue reading this article
by subscribing to our newsletter.
Subscribe now

A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.

If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.

Leave a Reply