Skip to content

Instantly share code, notes, and snippets.

@sethkontny
Forked from iharosi/useful-osx-commands.md
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sethkontny/062f2131d98a064fe212 to your computer and use it in GitHub Desktop.
Save sethkontny/062f2131d98a064fe212 to your computer and use it in GitHub Desktop.
Useful OS X commands

###Useful OS X commands

  1. App Store Debug menu

    Show

    defaults write com.apple.appstore ShowDebugMenu -bool true
    

    Hide

    defaults write com.apple.appstore ShowDebugMenu -bool false
    
  2. Remove extended attributes recursively

    xattr -rc <Folder>
    
  3. Delete Time Machine backups

    sudo /System/Library/Extensions/TMSafetyNet.kext/Helpers/bypass rm -rfv /Volumes/<Disk>/Backups.backupdb/<Folder>/
    
  4. Carbon copy a physical disk to an image (.dmg) file
    source: http://hints.macworld.com/article.php?story=20050302225659382

    dd bs=4096 if=/dev/rXX# of=/[TARGET DIR]/image.dmg conv=noerror,sync
    

    You have to dismount the partition first.
    Use the diskutil list and mount commands to discover the devices.

  5. Convert .png images to .jpg

    sips -s format jpeg ./*.png --out jpg/
    
  6. Resample image

    sips <source image> --resampleHeight <number> --out <directory>
    
  7. Finder Error -10810

    http://www.thexlab.com/faqs/error-10810.html

    /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -seed -rfv
    
  8. Query locked files

    lsof +c 0 | grep "\.Trash"
    
  9. Flush and Reset All DNS Caches in OS X Yosemite 10.10.4

    via http://osxdaily.com/2014/11/20/flush-dns-cache-mac-os-x/
    From OS X 10.10.4 moving onward, including 10.11, Apple has ditched discoveryd and has replaced it (or rather, reverted back to) mDNSResponder. Thus, to clear DNS caches in OS X Yosemite 10.10.4, and 10.11 El Capitan, and presumably onward, the command string is as follows:

    sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder;say cache flushed
    

    That command flushes all DNS caches for OS X 10.10.4+.

  10. Detailed Wi-Fi Connection History

    OS X Yosemite 10.10 and newer:

    defaults read /Library/Preferences/SystemConfiguration/com.apple.airport.preferences |grep LastConnected -A 7
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment