Skip to main content
3 of 8
code formatting
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}
    

Use a backup

If you have a Time Machine backup (or other backup of the system), you can restore the file from there. Browse to the folder in Finder and enter Time Machine, go back in time until the file is found then restore it.

Copy the file from another system or a trusted2 person's machine

If you have a second machine with a comparable build of OS X installed on it, you can copy the file from it. Feel free to ask for the checksum of a file in chat to compare it to if you wish to make sure that the file is correct (not modified accidentally/purposefully).

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.

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.

2 It's probably not best to trust random strangers on the internet for crucial system files.

grg
  • 205.6k
  • 45
  • 364
  • 495