Solved “bash: yum: command not found” [RHEL, Fedora, CentOS]

LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now

If you’re encountering the “bash: yum: command not found” error, it typically means that the YUM package manager is not installed on your system or the directory containing the yum executable is not included in your system’s PATH variable.

Let’s explore the reasons for this error in detail and learn the possible fixes.

Why “yum: command not found” Occur?

The most common reasons for the “yum command not found” error are:

  1. YUM not Installed: If you are unable to use the “yum” command, it could be that your system does not have the YUM package manager installed.
  2. PATH Configuration: The PATH on your system may not contain the path of “yum”.
  3. Permissions: If you’re encountering this error as a non-root user, it could be due to insufficient permissions.

How to Solve “yum: command not found” Error?

Follow the below methods to solve the “yum: command not found error” in Bash:

1. Add “yum” to PATH Variable

If YUM is installed but still the command isn’t found, it could be due to the YUM binary not being in the system’s PATH. In that case, you need to adjust the PATH environment variable. Follow the below steps to do that:

  1. Open the Bash terminal.
  2. Use the command below to check where yum is installed:
    which yum

    executing which yum command

  3. Now, add the path of yum executable into the PATH:
    export PATH=$PATH:/usr/bin/yum

    adding yum path to environment variableAfter applying the above solution, the error will be solved if it is due to a missing path variable.

Note: This method adds the PATH temporarily. If the method solves the problem, you can set the PATH variable of YUM permanently.

2. Install YUM

Most of the time, “bash: yum: command not found” occurs when the YUM package manager is not installed, or broken. In this instance, you need to install the YUM package manager to solve the error. To install YUM, follow the steps:

  1. Download the RPM file of YUM package manager for your Linux distribution.
  2. Install the package using dnf or rpm command:
    sudo dnf install <path/of/yum/rpm/file>

    Or,

    sudo rpm -i <path/of/yum/rpm/file>

    installing yum using dnf

    Note: If you get the error yum is already installed when running the command above, you need to force install it with --force. For example:
    sudo rpm -i <path/of/yum/rpm/file> --force
  3. Check if yum is working using:
    yum --version

    checking yum version

After installation, the yum command is executed successfully.

How to Set the PATH Variable for YUM Permanently?

To set the PATH variable for “yum” permanently, you need to add the directory of yum executable into the ~/.bashrc file. Follow the steps to do that:

  1. Open bashrc file using:
    nano ~/.bashrc
  2. Now paste the below lines at the end of the file:
    export PATH=$PATH:/usr/bin
    export PATH=$PATH:$(which yum)

    adding yum path variable to bashrc file

  3. Press CTRL+S to save, and CTRL+X to exit.
  4. Finally, reload the .bashrc file using:
    source ~/.bashrc

Conclusion

In conclusion, resolving the “bash: yum: command not found” issue involves ensuring the installation of the YUM package manager and configuring the system’s PATH appropriately. Applying these solutions allows you to seamlessly access yum commands within the Bash environment and streamline package management tasks in your RHEL, Fedora, or CentOS.

People Also Ask

What does “yum: command not found” mean?

The “yum: command not found” means the system is unable to find the YUM command, which is a package manager used primarily in RPM-based Linux distributions.

How to solve “yum: command not found” in CentOS 8?

To solve “yum: command not found” in CentOS, download the rpm package of YUM for CentOS using:

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm

Then, install it using dnf or rpm package manager. If the problem still exists, add yum to the PATH variable using:

export PATH=$PATH:$(which yum)

How to solve “yum: command not found” in Fedora 39?

To solve “yum: command not found” in Fedora 39, install YUM using sudo dnf install yum. Then, add yum to the PATH variable using export PATH=$PATH:$(which yum)

Related Articles


<< Go Back to [Solved] “bash: command not found” Error | Bash Error Handling and Debugging | Bash Scripting Tutorial

Rate this post
Ashikur Rahman

Hello, I’m Ashikur Rahman, currently working as a Linux Content Developer Executive at SOFTEKO. I have completed my graduation in Computer Science and Engineering from Khulna University of Engineering & Technology (KUET). Also, I’m pursuing my master’s in the same department at Bangladesh University of Engineering & Technology (BUET). I like to learn new technologies, contribute, and share those with others. Here my goal is to provide beneficial and user-friendly articles on Linux distribution for everyone. Read Full Bio

Leave a Comment