Abstract image with neony purple colors.

Installing, Removing, Upgrading and Managing Packages in Linux

This quick tutorial and cheat sheet will give you all the commands to install, remove and upgrade pages in most Linux distros, from Debian and Ubuntu to Red Hat, Fedora, CentOS, Arch and more.

Introduction to Package Management

Package management is a core aspect of using Linux. It involves installing, upgrading, and removing software to ensure a system has the required tools and applications. Each Linux distribution employs its own package management system, making the process slightly different across distros. This article explains the key commands for package installation, removal, and upgrading in popular distributions, focusing on their specific package managers.

Managing packages efficiently is essential for keeping a Linux system clean, updated, and functioning properly. While each distribution has its own tools and commands, the fundamental principles remain the same. Learning these commands for your specific distro will greatly enhance your Linux experience.

This guide starts with the basics: Installation, Removal and Upgrading, and then advances to more complex topics such as Local Installation, Removing Orphaned Packages, etc.

Note: If you wish to read a more general introduction to Linux Package Managers, follow this link: An Introduction to Linux Packages and Package Managers.


Debian-based Distributions (APT)

APT (Advanced Package Tool) is the package manager for Debian-based systems, such as Ubuntu, Linux Mint, and Pop!_OS (nice STEM focused distro, but an annoying to write name) .

Installing Packages

sudo apt update                        # Update the package list
sudo apt install package-name  # Install a package

Removing Packages

sudo apt remove package-name   # Removes the package but keeps configuration files
sudo apt purge package-name    # Removes the package along with configuration files

Upgrading Packages

sudo apt upgrade               # Upgrades all installed packages
sudo apt dist-upgrade          # Upgrades with dependency changes

Red Hat-based Distributions (YUM/DNF)

Red Hat-based systems, like Fedora, CentOS, and RHEL, use DNF (successor to YUM) for package management.

Installing Packages

sudo dnf install package-name  # Install a package

Removing Packages

sudo dnf remove package-name   # Removes a package

Upgrading Packages

sudo dnf upgrade               # Upgrades all installed packages
sudo dnf check-update          # Checks for available updates

Arch-based Distributions (Pacman)

Pacman is the package manager for Arch Linux and Arch-based systems like Manjaro.

Installing Packages

sudo pacman -S package-name    # Install a package

Removing Packages

sudo pacman -R package-name    # Removes a package
sudo pacman -Rns package-name  # Removes the package and its dependencies

Upgrading Packages

sudo pacman -Syu               # Syncs and upgrades all packages

openSUSE (Zypper)

Zypper is the package manager used in openSUSE distributions.

Installing Packages

sudo zypper install package-name  # Install a package

Removing Packages

sudo zypper remove package-name   # Removes a package

Upgrading Packages

sudo zypper update                # Updates all packages

Common Commands for Local Package Installation

Sometimes, you may download package files directly (.deb or .rpm) and install them manually.

Debian-based (.deb)

sudo dpkg -i package-name.deb     # Installs a .deb package
sudo apt --fix-broken install            # Fixes broken dependencies after installation

Red Hat-based (.rpm)

sudo rpm -ivh package-name.rpm    # Installs an .rpm package

For Red Hat systems, DNF is preferred for handling local packages:

sudo dnf install package-name.rpm # Installs an .rpm package

Removing Orphaned Packages

Orphaned packages are unused dependencies left after removing software. Each distro has tools to clean them up:

  • APT (Debian-based):
sudo apt autoremove

DNF (Red Hat-based):

sudo dnf autoremove

Pacman (Arch-based):

sudo pacman -Rns $(pacman -Qdtq)

Installing and Removing Local Packages

The alternative to installing packages from distributed repositories is downloading the package you want and performing a Local Install. You can read more about that following this link: How to Install and Remove Local Packages in Linux, From .deb to .rpm


Compiling Packages

Compiling packages is a much more deeper and complex topic. You can access the full guide following this link: How to Compile Packages in Linux and its Advantages.

Leave a Reply

Your email address will not be published. Required fields are marked *