In a stroke of sheer brilliance, I just chmod 750'ed my /usr and /etc directory on my VPS. Now, whenever I run sudo, I get -bash: sudo: command not found. Is there any way you can think of for me to restore access?

I tried to scp sudo over to the computer, but got a

bash: /etc/bash.bashrc: Permission denied
bash: scp: command not found
lost connection

If you can figure this one out, you're a genius.

link|improve this question
There are several possibilities in answers to this question. – Dennis Williamson Oct 30 '10 at 5:19
feedback

4 Answers

up vote 3 down vote accepted

Can you get a console to the machine? If so, reboot into recovery mode or some such thing (add kernel opts init=/bin/sh will drop a root shell). Then you'll be root, and can chmod as needed.

Other options include doing a bare metal restore (you've got a backup, right?) (If you don't you might be able to cobble something together from whatever is in /bin)

link|improve this answer
feedback

do su root instead of sudo

since su is often in /bin, you should not be impacted by your mistake

of course this requires you to know the root passwd...

link|improve this answer
Shoot, I don't know the root password. My user does have root privileges, though. – dlo Oct 30 '10 at 4:18
in that case i would just open up a support ticket and have someone at your vps provider fix the perms for you. – brad clawsie Oct 30 '10 at 4:46
feedback

Some VPS companies have web console access enabled. Check also that out.

link|improve this answer
feedback

Perhaps use netcat to transfer sudo over? At least on my Ubuntu (karmic) machine netcat is in /bin.

Unfortunately having the file won't help much since you'll need it to be setuid root for it to work and you won't have the permissions to make it so.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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