Skip to main content
Bounty Ended with 50 reputation awarded by bmike
explain benefits of this and risks - no internet, no reboot, potential version conflicts
Source Link
bmike
  • 241.3k
  • 80
  • 433
  • 958

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.

  1. Mount the Recovery HD

     diskutil mount Recovery\ HD
    
  2. Mount the BaseSystem.dmg

     hdiutil mount /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg
    
  3. 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.

If you 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 or without needing to boot into Recovery HD if you are OK modifying the system as it's running.

Use the Recovery partition

Many1 system files are also included on the Recovery partition and can be copied over.

  1. Mount the Recovery HD

     diskutil mount Recovery\ HD
    
  2. Mount the BaseSystem.dmg

     hdiutil mount /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg
    
  3. 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.

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 and without needing a 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.

  1. Mount the Recovery HD

     diskutil mount Recovery\ HD
    
  2. Mount the BaseSystem.dmg

     hdiutil mount /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg
    
  3. 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.

added warning to the text. This is more dangerous than a reinstall or a restore from backup or even copying the files when booted from recovery. But it's still a cool answer.
Source Link
bmike
  • 241.3k
  • 80
  • 433
  • 958

If you 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 or without needing to boot into Recovery HD if you are OK modifying the system as it's running.

Use the Recovery partition

Many1 system files are also included on the Recovery partition and can be copied over.

  1. Mount the Recovery HD

     diskutil mount Recovery\ HD
    
  2. Mount the BaseSystem.dmg

     hdiutil mount /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg
    
  3. 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.

Use the Recovery partition

Many1 system files are also included on the Recovery partition and can be copied over.

  1. Mount the Recovery HD

     diskutil mount Recovery\ HD
    
  2. Mount the BaseSystem.dmg

     hdiutil mount /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg
    
  3. 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.

If you 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 or without needing to boot into Recovery HD if you are OK modifying the system as it's running.

Use the Recovery partition

Many1 system files are also included on the Recovery partition and can be copied over.

  1. Mount the Recovery HD

     diskutil mount Recovery\ HD
    
  2. Mount the BaseSystem.dmg

     hdiutil mount /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg
    
  3. 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.

deleted 495 characters in body; added 291 characters in body
Source Link
grg
  • 205.6k
  • 45
  • 364
  • 495

Use the Recovery partition

Many1 system files are also included on the Recovery partition and can be copied over.

  1. Mount the Recovery HD

     diskutil mount Recovery\ HD
    
  2. Mount the BaseSystem.dmg

     hdiutil mount /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg
    
  3. 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.

Pacifist with OS X install media

If you've got an OS X install media and Pacifist, you can browse the install media and grab the file.

If you have Pacifist but no install media, it will prompt you to download the installer.

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.

Use the Recovery partition

Many1 system files are also included on the Recovery partition and can be copied over.

  1. Mount the Recovery HD

     diskutil mount Recovery\ HD
    
  2. Mount the BaseSystem.dmg

     hdiutil mount /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg
    
  3. Copy the file

     FILE="/usr/bin/codesign"
     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.

Pacifist with OS X install media

If you've got an OS X install media and Pacifist, you can browse the install media and grab the file.

If you have Pacifist but no install media, it will prompt you to download the installer.

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.

Use the Recovery partition

Many1 system files are also included on the Recovery partition and can be copied over.

  1. Mount the Recovery HD

     diskutil mount Recovery\ HD
    
  2. Mount the BaseSystem.dmg

     hdiutil mount /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg
    
  3. 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.

thin out some of the answers that exist elsewhere. Perhaps making a second answer that people can vote on / scan about copying the files from a trusted source would be good? I'd up vote it :-)
Source Link
bmike
  • 241.3k
  • 80
  • 433
  • 958
Loading
added 164 characters in body
Source Link
bmike
  • 241.3k
  • 80
  • 433
  • 958
Loading
code formatting
Source Link
grg
  • 205.6k
  • 45
  • 364
  • 495
Loading
Preserve permissions and make the file path clearly distinct from the base system path
Source Link
bmike
  • 241.3k
  • 80
  • 433
  • 958
Loading
Source Link
grg
  • 205.6k
  • 45
  • 364
  • 495
Loading