bash: sudo: command not found on OS X Lion
This baffles me.
sudo [any command here ]
bash: sudo: command not foundEek!
I tried to uninstall the Ruby Version Manager (it wouldn't compile Ruby for some reason). Somewhere in following their step-by-step instructions, I became sudo-less.
Here is my $PATH: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
which sudo returns nothing.
I figured I'd try a shot-in-the-dark while I was waiting. I have an older Mac that I just upgraded to Lion two days ago. I copied its /usr/bin/sudo onto the problem machine. Now when I attempt to sudo, I get:
sudo: must be setuid root
I'm not particularly savvy with the command line — this seems bad.
3 Answers
Try using Disk Utility to repair file permissions -- with any luck, that should reset the setuid bit on the /usr/bin/sudo that you copied. It's a flag that lets sudo act as root even when it's not run as root, which obviously it needs to be able to do, but you'll need sudo to set it using the command line so you have a chicken-and-egg problem.
0Did sudo ever disappear entirely? Did you replace it by the file you got from the other machine? I wonder how you even managed to delete sudo. RVM runs without elevated privileges, and it should never have had the permissions to do things like this.
Anyway, try and restore from your latest backup. If you don't have one, then repair permissions through Disk Utility. Might help.
You could attempt to boot the Mac into single user mode. Do this by holding Command-S while booting. Here, enter
mount -uw /And then try to chmod the file properly. Something along:
chown root /usr/bin/sudo
chmod u+s /usr/bin/sudoIf that all fails, just reinstall Lion – that's what recovery is for. It won't delete your files. You'd have to wipe the disk clean in order to lose anything, but I would strongly advise to make a backup.
I see Mike Scott's post answered your sudo issue, but I also hit the issue with RVM not compiling Rubies. It seems Apple shifted to using LLVM as the default compiler in 10.7 and so linked gcc to llvm-gcc.
$ which gcc
/usr/bin/gcc
$ ls -la /usr/bin/gcc
lrwxr-xr-x 1 root wheel 12 30 Nov 13:40 /usr/bin/gcc -> llvm-gcc-4.2gcc is still there, but it's at /usr/bin/gcc-4.2. Specifying the C Compiler to use by setting the CC environment variable should allow you to compile rubies.
$ CC=/usr/bin/gcc-4.2 rvm install 1.9.2