Mastering the 'yum' Command for Package Management (with examples)

Mastering the 'yum' Command for Package Management (with examples)

The yum command is a powerful package management utility used primarily for Red Hat Enterprise Linux (RHEL), Fedora, and CentOS (especially in older versions). It simplifies the process of installing, updating, and removing software applications, ensuring systems are up-to-date and secure. Understanding how to leverage yum can greatly enhance your system administration and management tasks.

Install a New Package

Code:

yum install package

Motivation:

Installing new software is one of the most common tasks for any Linux system administrator. The yum install package command is crucial for adding new applications and tools to your system’s repository, ensuring that you have the necessary programs to execute various functions or work with specific file types.

Explanation:

  • yum: This command initiates the Yellowdog Updater, Modified, which checks for available packages and handles the installation process.
  • install: A subcommand of yum that specifies the action to be taken—namely, to install the package specified.
  • package: This is the placeholder for the actual name of the package you wish to install, such as httpd for Apache or vim for the Vi text editor.

Example Output:

Resolving Dependencies
--> Running transaction check
---> Package package.x86_64 0:1.2.3-4.el7 will be installed
...
Installed:
  package.x86_64 0:1.2.3-4.el7
Complete!

Install a New Package and Assume Yes to All Questions

Code:

yum -y install package

Motivation:

Automation is key in modern IT environments. By using the -y option, administrators can script deployments and updates, allowing installations to proceed without manual intervention—ideal for scenarios where human oversight is limited, such as automated server setups or container building.

Explanation:

  • yum: Calls the yum package manager.
  • -y: This option automatically answers “yes” to all prompts during the installation process, removing any need for manual input and making the process faster and more efficient.
  • install: Indicates the action of installing a package.
  • package: The name of the desired package to install.

Example Output:

Resolving Dependencies
--> Running transaction check
---> Package package.x86_64 0:1.2.3-4.el7 will be installed
...
Installed:
  package.x86_64 0:1.2.3-4.el7
Complete!

Find the Package that Provides a Particular Command

Code:

yum provides command

Motivation:

Sometimes you might stumble upon a command that is not installed, and you’re unsure of which package it belongs to. This command is particularly useful for tracing a command back to its source package, allowing you to install it directly without guesswork.

Explanation:

  • yum: Initiates the yum utility.
  • provides: This subcommand searches the package database for the package that provides the specified command or file.
  • command: The name of the command that you want to trace back to its parent package.

Example Output:

command-1.2.3.x86_64 : Description of the package
Repo        : installed
Matched from:
Other       : /usr/bin/command

Remove a Package

Code:

yum remove package

Motivation:

Over time, systems accumulate unnecessary packages that might no longer be needed or could pose security risks if not updated. Removing such packages can help reduce system bloat and enhance security by eliminating potential vulnerabilities.

Explanation:

  • yum: Calls the package manager.
  • remove: The specific action to uninstall a given package or packages from your system.
  • package: The exact name of the package you wish to remove.

Example Output:

Removing:
 package.x86_64 0:1.2.3-4.el7
...
Removed:
  package.x86_64 0:1.2.3-4.el7
Complete!

Display Available Updates for Installed Packages

Code:

yum check-update

Motivation:

Keeping your software up-to-date is vital for maintaining system security and stability. The yum check-update command helps administrators identify packages that have updates available, enabling them to prioritize and apply important patches and enhancements.

Explanation:

  • yum: Engages the package manager.
  • check-update: This command checks the repositories for available updates, providing a list of updated versions for installed packages.

Example Output:

bash.x86_64  4.2.46-34.el7_9  base
bind-libs.x86_64  32:9.9.4-61.el7_9.1  updates
...

Upgrade Installed Packages to the Newest Available Versions

Code:

yum upgrade

Motivation:

Regular upgrades are essential to ensure that your system benefits from the latest features and security fixes. The yum upgrade command upgrades all installed packages on your system to their newest versions, safeguarding against vulnerabilities and improving functionality.

Explanation:

  • yum: Calls the package manager.
  • upgrade: A subcommand that instructs yum to update all installed packages to the latest versions available from configured repositories.

Example Output:

Resolving Dependencies
--> Running transaction check
---> Package package.x86_64 0:1.2.3-4.el7 will be upgraded
---> Package package.x86_64 0:1.2.3-5.el7 will be an update
...
Updated:
  package.x86_64 0:1.2.3-5.el7
Complete!

Conclusion:

The yum command is an indispensable tool for Linux system administrators, particularly those using RHEL, Fedora, or CentOS. Through this guide, we’ve explored essential yum use cases, providing insights into how to install, manage, and update packages effectively. By mastering these commands, you can greatly enhance your system’s performance, security, and functionality.

Tags :

Related Posts

Mastering 'pnpm outdated' Command (with examples)

Mastering 'pnpm outdated' Command (with examples)

The pnpm outdated command is a powerful tool for developers working with Node.

Read More
How to use the command 'laravel-zero' (with examples)

How to use the command 'laravel-zero' (with examples)

Laravel Zero is a command-line tool specifically designed for creating and managing applications based on the Laravel Zero framework.

Read More
How to Use the Command 'git help' (with Examples)

How to Use the Command 'git help' (with Examples)

The git help command is an essential tool for both novice and experienced Git users.

Read More