Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The command works if I don't prefix 'sudo', but then I get a permission error.

gem update --system

And if I use sudo it says the command is not found

sudo gem update --system

I'm on ec2, got into the server via SSH.

What do I do? From what I understand there is no pwd for sudo, and root is locked out.

share|improve this question

There is a current working directory for sudo, and there is also a PATH. I would recommend running which gem as a user, and then run echo $PATH as root (via sudo). If the path given by the first command isn't in the PATH given by the second, there's your problem, so just add it.

My guess is you're running some sort of user-centric rvm installation; the moment you do that, all bets are off as to the sane working of your system, vis a vis 99.9% of examples on the web. You need to learn a whole new way of working with your ruby installation.

share|improve this answer
no i'm not running rvm actually. – Blankman Jul 17 '11 at 4:15
which gem: /opt/ruby/bin/gem sudo echo $PATH: /opt/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/‌​games can you explain what I should be doing? adding /opt/ruby/bin/gem to my path? – Blankman Jul 17 '11 at 4:17
How in the name of flying furballs did gem end up in /opt/ruby? You didn't run echo $PATH as root, you ran echo /opt/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/‌​‌​games as root -- not the same thing, and a definite misleading data point. Yes, you should add /opt/ruby/bin to root's PATH. – womble Jul 17 '11 at 5:10
I installed REE, and it asked for a prefix which I have /opt/ruby. – Blankman Jul 17 '11 at 15:40
I'm on ec2, so I can't login as root, so I thought you meant to write 'sudo echo $PATH' when you said 'and then run echo $PATH as root (via sudo). So 'sudo echo $PATH' gives me: /opt/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/‌​games – Blankman Jul 17 '11 at 15:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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