Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

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

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)

share|improve this answer
add comment

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...

share|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
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

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.