What are apt and yum in Linux? Package Management in Linux
In the world of Linux, package management is a crucial aspect that enables users to install, update, upgrade, and remove software packages efficiently. Different Linux distributions use different package managers for handling software packages, and among the most popular are apt and yum. These tools provide a way to manage software, ensuring that users can easily keep their systems up-to-date and secure.
What Is a Package Manager?
A package manager is a tool or set of tools that automates the process of installing, upgrading, configuring, and removing software packages. It handles dependencies between packages and ensures that software is correctly integrated into the system.
Package managers typically interact with repositories, which are servers that host collections of software packages. They download packages from these repositories and manage their installation on your system.
Overview of apt and yum
1. apt (Advanced Package Tool)
apt is the package management tool used by Debian-based distributions, such as Debian, Ubuntu, Linux Mint, and many others. It handles .deb packages and is widely used for its simplicity and robust dependency management.
Common Commands
- Update the Package List:
sudo apt update
This command updates the package list from the repositories, ensuring that you have information about the latest software versions available.
- Upgrade Installed Packages:
sudo apt upgrade
Upgrades all the installed packages to their latest versions available in the repositories.
- Install a Package:
sudo apt install package_name
Replaces package_name with the name of the software you want to install. For example, to install the curl package:
sudo apt install curl
- Remove a Package:
sudo apt remove package_name
This command removes the specified package but leaves configuration files.
- Remove a Package Completely:
sudo apt purge package_name
Removes the package along with its configuration files.
- Search for a Package:
apt search package_name
Searches the repositories for packages that match the given name.
Example Use Case
If you want to install the git version control system on Ubuntu, you would run:
sudo apt update
sudo apt install git
This updates the package list and then installs git from the repositories.
2. yum (Yellowdog Updater Modified)
yum is the package management tool for RPM-based distributions, primarily used on CentOS, RHEL (Red Hat Enterprise Linux), and some older versions of Fedora. It manages .rpm packages and handles software installations and upgrades.
Note: On newer versions of CentOS (CentOS 8+) and Fedora, yum has been replaced with dnf, which has similar commands but offers improvements in performance and dependency management.
Common Commands
- Update the Package List:
sudo yum check-update
Checks for available updates for installed packages.
- Upgrade Installed Packages:
sudo yum update
Updates all installed packages to their latest versions.
- Install a Package:
sudo yum install package_name
For example, to install wget:
sudo yum install wget
- Remove a Package:
sudo yum remove package_name
Removes the specified package.
- Search for a Package:
yum search package_name
Searches for packages related to the given name.
Example Use Case
To install the httpd web server (Apache) on a CentOS system, you would run:
sudo yum install httpd
After installation, you can start the Apache service using:
sudo systemctl start httpd