If you don't mind or are sure your Recovery HD is patched to match the OS on your main system, you can snag a file and see if it works without needing to do a full reinstall of the OS orand without needing to boot into Recovery HD if you are OK modifying the system as it's runninga restart or an internet connection / saved installer.
Use the Recovery partition
Many1 system files are also included on the Recovery partition and can be copied over.
Mount the Recovery HD
diskutil mount Recovery\ HD
Mount the BaseSystem.dmg
hdiutil mount /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg
Copy the file
FILE="/usr/bin/codesign" sudo cp -p /Volumes/OS\ X\ Base\ System/${FILE} ${FILE}
This process can be combined into a single-line command if you have to run it frequently…
FILE="/usr/bin/codesign"; diskutil mount Recovery\ HD && hdiutil mount /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg && sudo cp -p /Volumes/OS\ X\ Base\ System/${FILE} ${FILE}
Even if you have deleted the cp
binary (which could happen), there is /usr/bin/ditto
, /usr/bin/tar
and several other commands that can stand in for cp
.
Reinstall OS X
If you've got the ability to reinstall OS X through the Recovery HD, Internet Recovery or an OS X install media then reinstalling OS X will 'repair' your install and copy any missing/broken system files back to your system.
I recommend that you do a permissions repair using Disk Utility after copying a file manually and then rebooting. If the fix works, now would be an excellent time for another backup snapshot.
1 Not all system files are on the Recovery HD, but many are. If the copying command doesn't work, check that the file exists on the Recovery HD.