How to manage software packages on Linux
Packages are archives containing binaries, configuration files, and dependency information for software. A package manager automates software installation, upgrades, and configuration, keeping track of all installed packages and their versions.
This guide covers package management on the following distributions:
- Debian
- Ubuntu
- CentOS
- AlmaLinux
Before you start
To complete the actions presented below, you must have:
Debian and Ubuntu: Using APT
On Debian and Ubuntu, use the APT (Advanced Package Tool) package manager.
How to update repositories
Update your package information with the following command:
sudo apt-get updateHow to update packages
After updating your repositories, upgrade your packages:
sudo apt-get upgradeHow to search for packages
Search for specific software packages, such as MariaDB:
apt-cache search mariadbHow to install a package
Install a package, for example, MariaDB server:
sudo apt-get install mariadb-serverHow to keep your system tidy
Remove unused dependencies:
sudo apt-get autoremoveHow to uninstall a package
Remove a package, for example, MariaDB server:
sudo apt-get remove mariadb-serverTo also remove all dependencies installed with the package:
sudo apt-get autoremove mariadb-serverCentOS and AlmaLinux: Using YUM/DNF
On CentOS and AlmaLinux, use the YUM (Yellowdog Updater, Modified) or DNF (Dandified YUM) package manager.
How to update repositories
Update your package information with the following command:
sudo yum updateOr, if using DNF:
sudo dnf updateHow to update packages
After updating your repositories, upgrade your packages:
sudo yum upgradeOr, if using DNF:
sudo dnf upgradeHow to search for packages
Search for specific software packages, such as MariaDB:
sudo yum search mariadbOr, if using DNF:
sudo dnf search mariadbHow to install a package
Install a package, for example, MariaDB server:
sudo yum install mariadb-serverOr, if using DNF:
sudo dnf install mariadb-serverHow to keep your system tidy
Remove unused dependencies:
sudo yum autoremoveOr, if using DNF:
sudo dnf autoremoveHow to uninstall a package
Remove a package, for example, MariaDB server:
sudo yum remove mariadb-serverOr, if using DNF:
sudo dnf remove mariadb-serverTo also remove all dependencies installed with the package:
sudo yum autoremove mariadb-serverOr, if using DNF:
sudo dnf autoremove mariadb-server