Recover command line after upgrading Mac OS – Installing Command Line Tools (Lion & Mountain Lion)

I love Apple and use my MB Pro for everything, from my personal everyday: mail, calendars, Facebook, etc. However, each time a new version of Mac OS is released, the SO moves further and further from Unix, and therefore from “standards”.

One of the consequences of this -among others- is that the known in linux OS as /bin moves around, making our .bashrc (yes, we do have that in Mac OS too) useless every time we upgrade. Since trying to add to the $PATH all the different folders each upgrade moves around is extremely painful, here it is an useful tip to recover the system commands from the terminal (e.g. git, gcc, javac, etc). (Please note that your own scripts, commands and binaries will remain the same and totally accessible as log as they are part of your $PATH).

In order to recover your system commands:

  • Open xcode. (If you do not have it, open the App Store and download it. Link here)
  • Xcode > Preferences

  • Click in Downloads > Command Line Tools > Install

After this if you open your terminal and type any command such as gcc, javac or git, it should work, just as it did before 🙂

Hope you find this useful!