Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I think i overwrote my /usr/local/bin folder - any way to undo this?

I was installing MacVim and did the following command:

sudo mv mvim /usr/local/bin

Now instead of copying mvim into my /usr/local/bin folder, i think it replaced that folder with a file called 'bin'...

Any suggestions?

share|improve this question
2  
You might have killed /usr/local/bin but not with those commands. touch foo; mkdir bar; mv foo bar puts the foo file inside the bar folder, whether or not the mv command ends with bar or bar/ or not. –  user588 Feb 22 '11 at 23:35

2 Answers 2

up vote 4 down vote accepted

Well, it's not a complete disaster. You could have done it to /usr/bin. The obvious first answer is restore it from a backup. If you don't have a backup then you can take some comfort in the fact that the /usr/local/bin directory isn't in the default search path for command-line executables without extra steps being taken so the damage you've caused is likely to be limited. Really, without a backup all you can do is reinstall apps which had files there. Without knowing what they were, you'll probably need to wait for apps to misbehave or crash and then you can try a reinstall to see if that fixes them. Hopefully you have Time Machine set up in which case it's a simple matter of following the procedure below:

  1. Open Terminal to run the following commands
  2. defaults write com.apple.finder AppleShowAllFiles TRUE
  3. killall Finder - this restarts Finder so it will show the hidden system files
  4. Open a Finder window for your Hard Drive
  5. Open usr, then local, then bin
  6. Launch Time Machine
  7. With the bin folder selected, scroll back in time in the time machine interface to your last successful backup of the /usr/local/bin folder and click restore in the bottom-right corner
  8. In a few moments, your folder will be restored.

Also, in future be very careful what you do with sudo and especially sudo mv. You can use sudo mv -i mvim /usr/local/bin/mvim and the -i will warn you instead of just overwriting whatever it finds at /usr/local/bin/mvim.

After you're done, you can hide the hidden files again by running the following commands in Terminal

  1. defaults write com.apple.finder AppleShowAllFiles FALSE
  2. killall Finder
share|improve this answer

You have Time Machine running, right? Just go in your Time Machine back a few hours and restore the file from there.

share|improve this answer

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.