DevOpsLesson
DevOpsLesson

Free, comprehensive DevOps tutorials and learning roadmaps. Master Docker, Kubernetes, CI/CD, and more.

Stay Updated

Get notified about new tutorials and features.

Tutorials

  • What is DevOps?
  • Docker Tutorial
  • Terraform Tutorial
  • CI/CD Pipeline
  • All Tutorials

Roadmaps

  • DevOps Engineer
  • Cloud Engineer
  • SRE Path
  • All Roadmaps

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 DevOpsLesson. All rights reserved.

DOCKERKUBERNETESTERRAFORMAWSCI/CDLINUXGITDEVOPS ROADMAPCLOUD ROADMAPSRE ROADMAPGIT CHEATSHEETDOCKER CHEATSHEETK8S CHEATSHEETTF CHEATSHEETLINUX CHEATSHEETDOCKERFILE LINTERYAML VALIDATORCRON PARSERREGEX TESTER

Linux Tutorial

Introduction to Linux
Linux Filesystem
Linux Navigation
Linux File Operations
Linux Text Processing
Linux Permissions
Linux Users and Groups
Linux Process Management
Linux systemd Basics
Linux Networking
Linux Disk and Storage
Linux Bash Scripting
Linux Package Management
Linux Environment Variables
Linux Cron Jobs
Linux SSH Keys
Linux Firewall Basics
Linux Log Management
Linux Performance Monitoring and Troubleshooting

Linux Package Management

PreviousPrev
Next

Learn how to install, update, remove, and manage software packages with APT, DNF, Snap, and AppImage on Linux.

Why Package Management Matters

Package managers give Linux a reliable way to install, update, and remove software. Instead of downloading random installers, you use repositories that track dependencies and supported versions.

For DevOps teams, that predictability matters. It helps with server provisioning, patching, image builds, and keeping systems consistent across environments.

APT on Ubuntu and Debian

On Ubuntu and Debian based systems, apt is the standard package tool.

Refreshing package metadata

sudo apt update

This updates the local package index so the system knows what versions are available.

Installing packages

sudo apt install nginx
sudo apt install git curl

APT automatically resolves dependencies, which is one reason package management is easier than manual installs.

Removing packages and cleanup

sudo apt remove nginx
sudo apt autoremove

apt remove uninstalls the chosen package. apt autoremove cleans up dependency packages that are no longer needed.

Listing package information

apt list --installed
apt list --upgradable
apt list nginx

These commands help you check what is installed, what can be upgraded, and whether a package exists.

Tip: A safe APT habit is apt update first, then inspect or install. Old package metadata often causes confusion.

DNF and YUM on RHEL, CentOS, and Fedora

Red Hat style distributions commonly use dnf. Older guides may say yum, but the workflow is very similar.

Installing and updating

sudo dnf install nginx
sudo dnf install git curl
sudo dnf update

Removing and listing

sudo dnf remove nginx
dnf list installed
dnf list available
dnf list nginx

The pattern is the same as APT: install trusted packages, update carefully, and remove software you do not need.

Note: Package names are not always identical across distributions. A package on Ubuntu may use a different name on Fedora or RHEL.

Snap and AppImage Basics

Traditional distro packages are not the only way to distribute Linux software.

Snap

Snap packages bundle applications in a more self-contained format.

sudo snap install code --classic
snap list
sudo snap remove code

Snaps are convenient across distributions, but they may use more disk space or start more slowly because more dependencies are bundled.

AppImage

An AppImage is usually one executable file that you download and run directly.

chmod +x MyTool.AppImage
./MyTool.AppImage

This is simple, but updates and lifecycle management are less centralized than with APT or DNF.

Holding or Pinning Versions

Sometimes you do not want the latest version immediately. Production systems may depend on a known-good release, or you may want to delay an upgrade until testing is complete.

Holding packages with APT

sudo apt-mark hold nginx
sudo apt-mark unhold nginx

A held package is skipped during normal upgrades.

APT can also use preference files under /etc/apt/preferences.d/ for stronger pinning rules when administrators need to prefer a specific version or repository.

Controlling versions with DNF

On RHEL style systems, administrators often manage versions through repository policy, explicit version installs, or the versionlock plugin when it is available.

sudo dnf install nginx-1.24.0
sudo dnf versionlock add nginx

Exact version locking support depends on the distribution and plugins installed, so it is worth checking your environment.

A Practical Workflow

Imagine you are preparing a VM for a web service. On Ubuntu you might do:

sudo apt update
sudo apt install nginx curl git
apt list --installed | grep nginx

On Fedora or RHEL you might do:

sudo dnf install nginx curl git
sudo dnf update

The details differ, but the logic stays the same:

  • refresh metadata when needed
  • install packages from trusted sources
  • remove unneeded software
  • keep version control in mind for stable systems

What You Should Remember

APT and DNF solve the same problem on different Linux families: managing software packages and dependencies. Snap and AppImage provide alternative distribution models, but repository-based package management remains central on most servers.

As you move into automation and operations, package management becomes part of repeatable infrastructure rather than one-off software installation.

Test Your Understanding

Exercise

Exercise 1: Refreshing package metadata

Which APT command refreshes the local package index without upgrading installed packages?

Exercise

Exercise 2: Removing leftover dependencies

After uninstalling a package on Ubuntu, which command is commonly used to remove dependencies that are no longer needed?

Exercise

Exercise 3: Understanding AppImage

What best describes an AppImage in Linux?

PreviousPrev
Next

Continue Learning

Linux Networking

Learn essential Linux networking commands for inspecting addresses, testing connectivity, transferring files, and understanding DNS resolution.

20 min·Medium

Linux Disk and Storage

Learn how to inspect disk space, mount filesystems, archive data, compress files, and find large files in Linux.

18 min·Medium

Linux Bash Scripting

Learn how to write practical Bash scripts with variables, conditionals, loops, functions, arrays, redirection, traps, and exit codes.

30 min·Hard

Explore Related Topics

Do

Docker Tutorials

Run and manage containers on Linux

Gi

Git Tutorials

Master Git version control on the command line

Try the Tool

Cron Parser

Parse and validate cron expressions with a visual schedule preview.

Regex Tester

Test and debug regular expressions used in Bash scripts and configs.

On This Page

Why Package Management MattersAPT on Ubuntu and DebianRefreshing package metadataInstalling packagesRemoving packages and cleanupListing package informationDNF and YUM on RHEL, CentOS, and FedoraInstalling and updatingRemoving and listingSnap and AppImage BasicsSnapAppImageHolding or Pinning VersionsHolding packages with APTControlling versions with DNFA Practical WorkflowWhat You Should RememberTest Your Understanding