Skip to content

Instantly share code, notes, and snippets.

@aromig

aromig/os-x_network.sh

Last active Nov 12, 2015
Embed
What would you like to do?
# Get device names of network adapters
networksetup -listallhardwareports
# Get network service order
networksetup -listnetworkserviceorder
# List wireless SSIDs
networksetup -listpreferredwirelessnetworks <device>
# Get and Set search domains
networksetup -getsearchdomains <networkservice>
networksetup -setsearchdomains <networkservice> <domain1> <domain2> <domain3> <...>
# Clear DNS cache
dscacheutil -flushcache
sudo killall -HUP mDNSResponder
# Get and Set Hostname
scutil --get LocalHostName
scutil --get ComputerName
scutil --get HostName
sudo scutil --set HostName <hostname>.<domain>
# Check if Remote Management is enabled
# First SSH to machine then run: (checks if daemon exists in /etc/ )
[[ -f /etc/RemoteManagement.launchd ]] && echo 'enabled' || echo 'disabled'
# Enable Remote Management
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -off -restart -agent -privs -all -allowAccessFor -allUsers
# Check if Screen Sharing is enabled
# First SSH to machine then run: (checks if daemon exists in /etc/ )
[[ -f /etc/com.apple.screensharing.agent.launchd ]] && echo 'enabled' || echo 'disabled'
# Enable Screen Sharing
sudo defaults write /var/db/launchd.db/com.apple.launchd/overrides.plist com.apple.screensharing -dict Disabled -bool false
sudo launchctl load /System/Library/LaunchDaemons/com.apple.screensharing.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment