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 LaunchPaddefaults delete com.apple.dock; killall Dock # reset the Dock
Imaging / Deployment
softwareupdate --list-full-installers # display available macOS installers for downloadsoftwareupdate --fetch-full-installer --full-installer-version **.**.* # download a specific macOS version installer
Network
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder # clear dns cachesudo killall -HUP mDNSResponder # macOS 10.14 – Mac OS X 10.7sudo discoveryutil udnsflushcaches # macOS 10.10 onlysudo dscacheutil -flushcache # Mac OS X 10.6sudo lookupd -flushcache # Mac OS X 10.5lookupd -flushcache # Mac OS X 10.4
Sharing & Services
sudo launchctl print system/ # list all servicessudo scutil --set HostName “Host Name” # set hostname (useful if there is a mismatch between sharing preferences and the shellsudo launchctl load -w /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist # enable AFP sharing on macOS Catalina and earliersudo launchctl load -w /System/Library/LaunchDaemons/com.apple.smbd.plist # enable SMB file sharing