How to use the command "yum" (with examples)

How to use the command "yum" (with examples)

The “yum” command is a package management utility specifically designed for use in RHEL (Red Hat Enterprise Linux), Fedora, and CentOS distributions. It allows users to easily install, update, and remove packages, as well as manage dependencies between different packages.

Use case 1: Installing a new package

Code:

yum install package

Motivation: Installing new packages is a common task when setting up a Linux system. The “yum install” command makes it simple and straightforward to add new software or libraries to your system.

Explanation:

  • “yum”: The command itself.
  • “install”: The subcommand that instructs yum to install a package.
  • “package”: The name of the package you want to install.

Example output:

Downloading packages:
Package package-1.0.rpm is already installed.
Nothing to do.

Use case 2: Installing a new package and assuming yes to all questions

Code:

yum -y install package

Motivation: In certain situations, such as automated updates or batch installations, it is advantageous to assume “yes” to all questions and proceed with the installation automatically.

Explanation:

  • “yum”: The command itself.
  • “-y”: Option to assume “yes” to all questions.
  • “install”: The subcommand that instructs yum to install a package.
  • “package”: The name of the package you want to install.

Example output:

Downloading packages:
Package package-1.0.rpm is already installed.
Nothing to do.

Use case 3: Finding the package that provides a particular command

Code:

yum provides command

Motivation: When encountering an error indicating a missing command, it is often helpful to identify the package that provides that command. The “yum provides” command simplifies this process.

Explanation:

  • “yum”: The command itself.
  • “provides”: The subcommand that instructs yum to search for the package providing a specific command.
  • “command”: The command you want to search for.

Example output:

package-1.0.rpm

Use case 4: Removing a package

Code:

yum remove package

Motivation: Removing unnecessary or no longer needed packages helps to keep your system clean and efficient. The “yum remove” command ensures that packages are removed correctly, along with any associated dependencies.

Explanation:

  • “yum”: The command itself.
  • “remove”: The subcommand that instructs yum to remove a package.
  • “package”: The name of the package you want to remove.

Example output:

Removing package-1.0.rpm
Dependencies resolved.
===============================================================================
 Package             Architecture   Version            Repository           Size
===============================================================================
Removing:
 package             x86_64         1.0                updates              10 MB
Removing for dependencies:
 dependencies        x86_64         2.0                updates              5 MB

Transaction Summary
===============================================================================
Remove  1 Package (+1 Dependent package)

Installed size: 15 MB
Is this ok? [y/N]: y
Downloading packages:
Running transaction check
Package dependencies-2.0.rpm is already installed.
Nothing to do.
Complete!

Use case 5: Displaying available updates for installed packages

Code:

yum check-update

Motivation: Keeping your system up-to-date is crucial for security, stability, and performance reasons. The “yum check-update” command provides a quick way to check for available updates without installing them.

Explanation:

  • “yum”: The command itself.
  • “check-update”: The subcommand that instructs yum to check for available updates.

Example output:

package-1.0.rpm                x86_64          1.1                updates

Use case 6: Upgrading installed packages to the newest available versions

Code:

yum upgrade

Motivation: Regularly upgrading installed packages ensures that your system benefits from bug fixes, security patches, and new features. The “yum upgrade” command simplifies the process of upgrading packages.

Explanation:

  • “yum”: The command itself.
  • “upgrade”: The subcommand that instructs yum to upgrade installed packages to the newest available versions.

Example output:

Updating:
 package                           x86_64         1.0-1.1              updates
Dependencies updated.
Complete!

Conclusion:

In this article, we have explored various use cases of the “yum” command. From installing new packages to upgrading existing ones, “yum” offers a comprehensive set of features for package management in RHEL, Fedora, and CentOS distributions. By utilizing these use cases, users can effectively manage software and dependencies on their Linux systems.

Tags :

Related Posts

How to use the command 'sacct' (with examples)

How to use the command 'sacct' (with examples)

The ‘sacct’ command is used to display accounting data from the Slurm service.

Read More
How to use the command Out-String (with examples)

How to use the command Out-String (with examples)

The Out-String command is used in PowerShell to output input objects as a string.

Read More
How to use the command chown (with examples)

How to use the command chown (with examples)

The ‘chown’ command is used to change the user and group ownership of files and directories in Linux.

Read More