Useful Commands


Here is a list of commands that can be helpful in administration and troubleshooting on Mac’s:

Desktop, Dock & LaunchPad
  • defaults write com.apple.dock ResetLaunchPad -bool true; killall Dock # reset LaunchPad
  • defaults delete com.apple.dock; killall Dock # reset the Dock
Imaging / Deployment
  • softwareupdate --list-full-installers # display available macOS installers for download
  • softwareupdate --fetch-full-installer --full-installer-version **.**.* # download a specific macOS version installer
Network
  • sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder # clear dns cache
    • sudo killall -HUP mDNSResponder # macOS 10.14 – Mac OS X 10.7
    • sudo discoveryutil udnsflushcaches # macOS 10.10 only
    • sudo dscacheutil -flushcache # Mac OS X 10.6
    • sudo lookupd -flushcache # Mac OS X 10.5
    • lookupd -flushcache # Mac OS X 10.4
Sharing & Services
  • sudo launchctl print system/ # list all services
  • sudo scutil --set HostName “Host Name” # set hostname (useful if there is a mismatch between sharing preferences and the shell
  • sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist # enable AFP sharing on macOS Catalina and earlier
  • sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.smbd.plist # enable SMB file sharing