Package management in CentOS is primarily done using the yum (Yellowdog Updater, Modified) or dnf (Dandified Yum) commands. These package managers allow users to install, remove, update, and manage software packages on their CentOS systems. Here's an overview of how to use yum or dnf for package management:
1. Updating Package Repositories:
- Before installing or updating packages, it's essential to update the package repositories to ensure you have the latest information about available packages. Use one of the following commands:
orsudo yum updatesudo dnf update
2. Installing Packages:
- To install a package, use the
installoption followed by the package name. For example:
orsudo yum install package_namesudo dnf install package_name - Replace
package_namewith the name of the package you want to install.
3. Removing Packages:
- To remove a package, use the
removeoption followed by the package name. For example:
orsudo yum remove package_namesudo dnf remove package_name - Replace
package_namewith the name of the package you want to remove.
4. Searching for Packages:
- You can search for packages using the
searchoption followed by a keyword. For example:
oryum search keyworddnf search keyword - Replace
keywordwith the term you want to search for.
5. Listing Installed Packages:
- To list installed packages, you can use the
listoption. For example:yum list installeddnf list installed
6. Updating Packages:
- To update installed packages to the latest available versions, you can use the
updateoption. For example:sudo yum updatesudo dnf update
7. Additional Commands:
- Both
yumanddnfoffer additional commands and options for advanced package management tasks, such as package group management, dependency resolution, and system upgrade procedures.
8. Differences Between yum and dnf:
dnfis the next-generation package manager and is the default in newer versions of CentOS (such as CentOS 8).dnfoffers improved performance, dependency resolution, and additional features compared toyum.- While
yumis still available in CentOS 8, it's recommended to usednffor package management tasks.

Comments