How to Fix “Yum command not found” error

Different Linux-based operating systems have various package managers for installing, removing, and managing software. For example, the apt in Ubuntu is a pre-installed repository that allows the user to retrieve various software from its collection and install it using the terminal. Similar to the apt repository in Ubuntu, yum exists in RHEL OS(Red Hat Enterprise Linux) which is another Linux-based OS. Yum helps to update, install, and manage packages. When making use of the yum tool, an error with the statement “yum command not found” may be encountered.

This article will provide knowledge regarding the reasoning behind this error as well as the necessary steps that need to be taken to resolve this issue.

Resolve the “yum command not found” problem

There are various causes that will invoke this problem. This section will shed some light on the major causes behind this issue as well as the possible solutions to it.

Reason 1: Yum package is Missing

The first and most obvious reason for any “command not found” error is a missing package. The yum package usually comes preinstalled into the RHEL OS. But if for some reason, the yum package gets removed, this error will occur. To verify whether this is true, the packet manager can be used. Run the command shown below:

# rpm -q yum

If the command above shows the “package yum is not installed” message, then it means that the Yum package is indeed missing.

Solution: Install Yum

To resolve this issue, the yum package needs to be installed on the system. This can be achieved using the command shown below:

# sudo dnf install yum

The dnf tool is utilized to install the yum package onto the system. Once installed, the error “yum command not found” should no longer occur.

Reason 2: Wrong Linux OS

Another very likely problem that can occur is that you are trying to run the yum command on a Debian-based OS such as Ubuntu. Yum is not a valid package on Ubuntu and if you try to run this command on Ubuntu, then the error will be invoked as shown below:

Solution: Run a Valid Command for your OS

If you are using the Ubuntu OS, it is important that you do not use the yum command. The “apt” is the package manager of Debian based system just like yum in RHEL. For instance, the “apt” package manager is used in the case of Ubuntu:

Reason 3: Path not Specified

Oftentimes, the path of the yum package is not specified. This can cause the “command not found” error to be prompted in front of the user even though the package is installed on the computer.

Solution: Specify the Full Path

The only solution for the path problem is to specify the full path of the package in the terminal. This will check for us whether the package exists on that path or not. Below is a sample command for that:

# /usr/bin/yum

If the above-mentioned command prompts the “-bash: yum: command not found” problem, then this means that the path is not the issue and the package simply does not exist on the system.

Conclusion

There are 3 possible causes for this issue. Either the yum package is not installed, its path is not specified, or the yum command is being used on the wrong operating system. To resolve this issue, you can install the yum package on your system or specify its path if it is already installed. Furthermore, you also need to make sure that you are not using the yum command on a Debian-based operating system. This article has provided the reasons and the possible solutions to the error “Yum command not found”