Using yum in CentOS

Introduction

yum is one of the package management tools used in CentOS for managing software packages. It simplifies the process of installing, updating, and removing software packages, and automatically resolves dependencies, making package management more convenient and efficient.

Functions

yum mainly has the following functions:

  • Install packages: Install desired software packages with simple commands, without the need to manually download and resolve dependencies.
  • Update packages: Update installed packages to the latest versions to ensure system security and stability.
  • Remove packages: Remove unnecessary packages from the system to free up disk space and keep the system clean.
  • Search packages: Find and display information about available packages, including package names, versions, and dependencies.
  • Manage repositories: Manage repository configurations to obtain packages from different sources.

Use Cases

yum is particularly useful in the following scenarios:

  • Software installation and updates: Quickly install and update software packages, including system tools, development libraries, services, etc.
  • System maintenance and management: Update system patches, security updates, and manage the system's software environment.
  • Autoamted deployment: Use yum via scripts or automation tools to deploy software and services, simplifying the deployment process.

Installing yum

In most CentOS distributions, yum is installed by default. If yum is not installed on your system, you can install it using the following command:

sudo yum install yum

Configuring yum Repositories

yum uses repositories to obtain software packages. You can configure yum repositories by editing .repo files in the /etc/yum.repos.d/ directory. Here are the basic steps to configure a yum repository:

  1. Choose a suitable yum repository, such as the CentOS official repository, EPEL, etc.
  2. Create a file ending with .repo, for example, myrepo.repo.
  3. Add the repository configuration information to the file, for example:
[myrepo]
name=My Custom Repository
baseurl=http://example.com/myrepo
enabled=1
gpgcheck=0

Here, [myrepo] is the repository ID, name is the repository name, baseurl is the URL of the repository, enabled indicates whether the repository is enabled, and gpgcheck indicates whether to check GPG signatures.

  1. Save and exit the file editor.

Installing Software with yum

To install software using yum, simply execute the following command in the terminal:

sudo yum install package_name

Where package_name is the name of the software package to install. yum will automatically download and install the package along with its dependencies.

To update installed packages, execute:

sudo yum update

This will update all installed packages on the system to they latest versions.

Through the above introduction, you should understand the importance and basic usage of yum in CentOS, as well as how to install, configure, and use it to manage software packages on the system.

Tags: Yum centos Package Management

Posted on Wed, 14 Oct 2026 16:19:47 +0000 by fredfish666