Skip to content

Instantly share code, notes, and snippets.

@andiMenge
Last active July 6, 2018 13:11
Show Gist options
  • Select an option

  • Save andiMenge/bc36507f94c0e33dc8913037593103b9 to your computer and use it in GitHub Desktop.

Select an option

Save andiMenge/bc36507f94c0e33dc8913037593103b9 to your computer and use it in GitHub Desktop.
usefull macOS stuff to remember

macOS

System Preferences

Toggle automatic software updates

sudo softwareupdate --schedule <off|on>

Change various Preferences

  • usage defaults usage
  • list all config domains defaults domains |tr ‘,’ '\n’
  • show appstore prefs defaults read com.apple.appstore

src

App Store

  • install app store apps from command line brew install mas mas list

Launchd

Debugging Launchd services

search in system.log for the label of your .plist. This can be done easiely in the console app.

Daemon Example

foo.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
    <string>node_exporter</string>
   <key>Program</key>
   <string>/usr/local/bin/node_exporter</string>
   <key>KeepAlive</key>
    <true/>
</dict>
</plist>
  • start daemon launchctl load ./node-exporter.plist
  • stop daemon launchctl unload ./node-exporter.plist

Keychain

  • Create Keychain security create-keychain -p <pw> <name>.keychain
  • Add Keychain to search list security list-keychains -d user -s login.keychain <name>.keychain

Automatic Unlocking at startup

$HOME/Library/LaunchAgents/unlock.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
    <string>unlock</string>
   <key>ProgramArguments</key>
        <array>
                <string>security</string>
                <string>unlock-keychain</string>
                <string>-p</string>
                <string>MyPassword</string>
                <string>/Users/admin/Library/Keychains/test.keychain-db</string>
        </array>
   <key>RunAtLoad</key>
   <true/>
</dict>
</plist>

Change User Password

dscl . -passwd /Users/<my-user>

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