Enable Location Services With A Bash Script
· 5min
This script is intended for workflows where macOS devices need Location Services turned on as part of a managed flow, for example during onboarding or before running location dependent tooling in IT or security. Instead of walking users through System Settings by hand, the script enables Location Services at the system level and restarts the locationd service so the change takes effect immediately.
It is designed to be run as root on a managed device, for example through Jamf Pro or another MDM agent, and has been tested on macOS 15.3.1. On some older macOS versions you may also need to kickstart the locationd launch daemon after updating the preference, which is noted in the comments.
main.tf
#!/bin/sh
###
#
#
# Created : 2025-02-02
# Version : 1.0
# Tested with : macOS 15.3.1
#
###
defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1
killall locationd
# For older macOS, can't remember which version, add this.
# launchctl kickstart -k system/com.apple.locationd