Package management in Linux is essential for installing, updating, and removing software packages. Different distributions use different package managers, but the core concepts remain similar.
APT (Advanced Package Tool):
Used by: Debian-based distributions (e.g., Ubuntu).
Commands:
apt update
: Updates the package list from repositories.
apt install package
: Installs a new package.
apt upgrade
: Upgrades all installed packages to their latest versions.
apt remove package
: Removes a package but leaves configuration files.
apt purge package
: Removes a package along with its configuration files.
Example:
sudo apt update
sudo apt install vim
sudo apt remove vim
YUM (Yellowdog Updater, Modified):
Used by: Older Red Hat-based distributions (e.g., CentOS, Fedora before version 22).
Commands:
yum update
: Updates the package list and installs updates.
yum install package
: Installs a new package.
yum remove package
: Removes a package.
yum search package
: Searches for a package in the repositories.
Example:
sudo yum install httpd
sudo yum remove httpd
DNF (Dandified YUM):
Used by: Red Hat-based distributions (e.g., Fedora, CentOS, RHEL from version 8 onwards).
Commands: Similar to YUM but with improvements in speed and dependency resolution.
dnf update
: Updates the package list and installs updates.
dnf install package
: Installs a new package.
dnf remove package
: Removes a package.
dnf search package
: Searches for a package in the repositories.
Example:
sudo dnf install nginx
sudo dnf remove nginx
Pacman:
Used by: Arch Linux and its derivatives.
Commands:
pacman -Syu
: Synchronizes the package database and updates the system.
pacman -S package
: Installs a new package.
pacman -R package
: Removes a package.
pacman -Ss package
: Searches for a package in the repositories.
Example:
sudo pacman -Syu
sudo pacman -S neofetch
sudo pacman -R neofetch
Installing a Package:
APT: sudo apt install package
YUM: sudo yum install package
DNF: sudo dnf install package
Pacman: sudo pacman -S package
Example:
sudo apt install git # Install Git using APT
sudo dnf install git # Install Git using DNF
sudo pacman -S git # Install Git using Pacman
Updating Packages:
APT: sudo apt update && sudo apt upgrade
YUM: sudo yum update
DNF: sudo dnf update
Pacman: sudo pacman -Syu
Example:
sudo apt update && sudo apt upgrade # Update package list and upgrade installed packages using APT
sudo dnf update # Update all packages using DNF
sudo pacman -Syu # Sync and update packages using Pacman
Removing a Package:
APT: sudo apt remove package
YUM: sudo yum remove package
DNF: sudo dnf remove package
Pacman: sudo pacman -R package
Example:
sudo apt remove apache2 # Remove Apache2 using APT
sudo dnf remove apache2 # Remove Apache2 using DNF
sudo pacman -R apache # Remove Apache using Pacman
These package management tools allow you to easily manage the software on your Linux system, ensuring you have the latest updates and can efficiently manage dependencies and installations.
Go back to topics page Linux Basics.