CentOS uses two primary package management tools: YUM (Yellowdog Updater, Modified) and DNF (Dandified YUM). Here’s a detailed overview of how package management works in CentOS:
YUM (Yellowdog Updater, Modified):
DNF (Dandified YUM):
Here are some common commands for both YUM and DNF:
sudo yum install package_name
sudo dnf install package_name
sudo yum update
sudo dnf update
sudo yum remove package_name
sudo dnf remove package_name
yum search package_name
dnf search package_name
yum list installed
dnf list installed
yum info package_name
dnf info package_name
Package managers rely on repositories to download packages. You can enable or disable repositories using configuration files.
View enabled repositories:
yum repolist # For YUM
dnf repolist # For DNF
Adding a new repository:
You can create a .repo file in /etc/yum.repos.d/ for YUM or DNF. For example:
[myrepo]
name=My Repository
baseurl=http://my.repo.url/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://my.repo.url/RPM-GPG-KEY
While YUM and DNF are more user-friendly, you can also use the RPM command directly for package management:
sudo rpm -ivh package.rpm
sudo rpm -e package_name
rpm -q package_name
yum update or dnf update to ensure your system is secure and up to date.dnf upgrade: Use this command to upgrade all packages and their dependencies to the latest versions.dnf clean all