Skip to content

Instantly share code, notes, and snippets.

@iharosi
Last active September 21, 2023 07:25
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save iharosi/8022729de316fddf8623 to your computer and use it in GitHub Desktop.
Save iharosi/8022729de316fddf8623 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 10.10+

    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
    
  11. How to Repair Disk Permissions in OS X El Capitan from Command Line

    via: http://osxdaily.com/2015/11/04/verify-repair-permissions-mac-os-x/

    sudo /usr/libexec/repair_packages --repair --standard-pkgs --volume /
    
  12. Configuring Split Tunnel for VPN

via: https://documentation.meraki.com/MX-Z/Client_VPN/Configuring_Split-tunnel_Client_VPN

First, disable full tunnel (all traffic over the VPN):

  1. Navigate to the specific VPN settings for OS X, located under System Preferences > Network.
  2. Click Advanced Settings
  3. Under "Options" section, deselect “Send all traffic over VPN”

Add a new route to local routing table:

  1. Connect to the Client VPN
  2. Open the Terminal Application; normally this is located in Applications > Utilities > Terminal
  3. Verify the PPP interface that is being used for the Client VPN, this can be done by typing ifconfig
  4. As a superuser, enter the following command, replacing the relevant information between the <> markings: Note: "Destination subnet" refers to the local LAN subnet on the appliance's site, not the Client VPN subnet specified in Dashboard.
Route add -net <destination subnet>/<subnet mask in CIDR notation> -interface <VPN interface>

Example: sudo route add 10.0.1.0/24 –interface ppp0

To verify that the route was added take a look at the routing table, the new subnet should now have an entry. The route table can be accessed by typing netstat -r.

The route table will have to be modified depending on what networks will be accessed over the Client VPN (e.g. more than one network behind the concentrator). The interface will also have to be modified if there is more than one VPN configured on the client.

@Schleipnir74
Copy link

"/System/Library/Extensions/TMSafetyNet.kext/Helpers/bypass" should be "/System/Library/Extensions/TMSafetyNet.kext/Contents/Helpers‌/bypass".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment