I am running a Amazon ec2 instance on amazon's linux.

Whenever I run anything sudo yum it give me this:

sudo: yum: command not found

ec2-user$ rpm -qf /usr/bin/yum

ec2-user$ which yum

which yum while in root gives:

root$ which yum
/usr/bin/which: no yum in (/sbin:/bin:/usr/sbin:/usr/bn:/usr/local/bin:/opt/aws/bin)

This is a new ec2 instance two days old. When I first logged in I ran sudo yum update and everything wen't well. What changed?


You have a typo in root's PATH.

Instead of /usr/bin the path entry reads /usr/bn.

I can't be sure if this is because Amazon has screwed up something, or you made a change to your PATH and accidentally deleted the i, but that appears to be the cause of the problem.

| improve this answer | |
  • Where can I change that? – ThomasReggi Nov 28 '12 at 16:12
  • Wherever you set it initially. Perhaps in .bashrc? Though if you didn't set it, it's probably Amazon's fault. I'm not at all impressed with Amazon Linux and I don't recommend it. – Michael Hampton Nov 28 '12 at 16:22
  • I never set it. – ThomasReggi Nov 28 '12 at 16:32
  • OK, my recommendation will be "Don't use Amazon Linux". They seem to have a history of breaking important stuff at random times. A real DevOps thing to do, but out here in the real world, we need stable systems. – Michael Hampton Nov 28 '12 at 16:33
  • Gosh, you may be right. Added export PATH=/usr/bin:$PATH to /root/.bashrc and the error still happened. I had to sudo su and run yum.... – ThomasReggi Nov 28 '12 at 16:34

Found the answer here: Passing PATH through sudo

sudo nano /etc/sudoers
ctrl + w (nano search)
replaced it with "usr/bin"
| improve this answer | |
  • 1
    while this may work, you should almost always use visudo to edit sudoers (export EDITOR=nano first) as it will check the syntax before writing the file; if you mess it up (and it's very easy to do ... been there), you can make it impossible to use sudo, which means your server is hosed. Also, I think the answer from Michael Hampton above deserves a checkmark, perhaps with a note indicating you also found the sudoers was also messed up. – Tom Harrison Jr Nov 29 '12 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.