0
0
Linux-cliHow-ToBeginner · 3 min read

How to Use yum Command in Linux: Basic Syntax and Examples

The yum command in Linux is used to manage software packages by installing, updating, or removing them. You use it with options like install, update, or remove followed by the package name to perform actions.
📐

Syntax

The basic syntax of the yum command is:

  • yum [options] command [package_name]

Here, command is the action you want to perform like install, update, or remove. The package_name is the name of the software package you want to manage. Options modify the behavior of the command.

bash
yum [options] command [package_name]
💻

Example

This example shows how to install the wget package using yum. It downloads and installs the package and its dependencies.

bash
sudo yum install wget
Output
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed ... Installed: wget.x86_64 0:1.14-18.el7_6.1 Complete!
⚠️

Common Pitfalls

Common mistakes include:

  • Running yum commands without sudo, causing permission errors.
  • Typing wrong package names, leading to "No package found" errors.
  • Not updating the package list before installing, which can cause outdated packages to be installed.

Always run sudo yum update before installing new packages to get the latest versions.

bash
yum install wget
sudo yum install wget
Output
Error: You need to be root to perform this command Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed ... Installed: wget.x86_64 0:1.14-18.el7_6.1 Complete!
📊

Quick Reference

CommandDescription
yum install Install a package
yum update Update a package
yum remove Remove a package
yum list installedList installed packages
yum search Search packages by keyword
yum updateUpdate all packages

Key Takeaways

Use yum with commands like install, update, and remove to manage packages.
Always run sudo before yum commands to avoid permission errors.
Update your package list with yum update before installing new software.
Check package names carefully to avoid errors during installation.
Use yum list installed to see what software is already on your system.