Yum command not found on CentOS/RHEL server

This is a new problem I am getting whenever I run yum install htop, I am getting the following error on my screen:

-bash: yum: command not found

How do I fix this error on a CentOS 7 Linux server?

Yum is located at /usr/bin/yum. Make sure yum is in path:

echo "$PATH"

You can always set path as follows:

export PATH=$PATH:/usr/bin

For root user PATH should be as follows:


Make sure yum can be located:

type -a yum

Once found you can run it as follows:

yum update
yum install htop
/usr/bin/yum update

If yum is missing you can install it from DVD/CD. You need to locate a package called yum*.rpm and install it with:

rpm -ivh /path/to/cdrom/yum*.rpm
[root@samratsukhi Link to Linux Programs]# rpm -ivh /path/to/cdrom/yum*.rpm
error: File not found by glob: /path/to/cdrom/yum*.rpm
[root@samratsukhi Link to Linux Programs]# rpm -ivh yum*.rpm
warning: yum-4.2.19-1.1.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f6ab3975: NOKEY
error: Failed dependencies:
	dnf = 4.2.19-1.1 is needed by yum-4.2.19-1.1.noarch
	dnf >= 4.2.17 is needed by yum-utils-4.0.14-1.1.noarch
	dnf-plugins-core = 4.0.14-1.1 is needed by yum-utils-4.0.14-1.1.noarch
	python3-dnf >= 4.2.17 is needed by yum-utils-4.0.14-1.1.noarch

Are you using CentOS 8? Either way install those packages too using the rpm:

rpm -ivh dnf*.rpm python3-dnf*.rpm yum*.rpm

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki