Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
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.
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) .
sudo apt update # Update the package list
sudo apt install package-name # Install a package
sudo apt remove package-name # Removes the package but keeps configuration files
sudo apt purge package-name # Removes the package along with configuration files
sudo apt upgrade # Upgrades all installed packages
sudo apt dist-upgrade # Upgrades with dependency changes
Red Hat-based systems, like Fedora, CentOS, and RHEL, use DNF (successor to YUM) for package management.
sudo dnf install package-name # Install a package
sudo dnf remove package-name # Removes a package
sudo dnf upgrade # Upgrades all installed packages
sudo dnf check-update # Checks for available updates
Pacman is the package manager for Arch Linux and Arch-based systems like Manjaro.
sudo pacman -S package-name # Install a package
sudo pacman -R package-name # Removes a package
sudo pacman -Rns package-name # Removes the package and its dependencies
sudo pacman -Syu # Syncs and upgrades all packages
Zypper is the package manager used in openSUSE distributions.
sudo zypper install package-name # Install a package
sudo zypper remove package-name # Removes a package
sudo zypper update # Updates all packages
Sometimes, you may download package files directly (.deb or .rpm) and install them manually.
sudo dpkg -i package-name.deb # Installs a .deb package
sudo apt --fix-broken install # Fixes broken dependencies after installation
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
Orphaned packages are unused dependencies left after removing software. Each distro has tools to clean them up:
sudo apt autoremove
DNF (Red Hat-based):
sudo dnf autoremove
Pacman (Arch-based):
sudo pacman -Rns $(pacman -Qdtq)
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 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.