Category filter
Turn on/off location services on Mac using scripts
Location Services enable several macOS applications and services to gather and use information based on the current location of the Mac, which in turn enhances the user experience. There are certain apps like Maps, for instance, which require the current location of the device to function effectively. This information is collected and provided by Location Services. However, by enabling Location Services the possibility for security threats such as tracking online behavior, theft of identity and lack of privacy in general increases. It is the IT admin’s discretion whether or not to enable/disable Location Services on their fleet of devices.
Location Services can be enabled/disabled for the Mac altogether and if enabled, it can be enabled/disabled for each app/service individually. In this document, we provide scripts which IT admins can use to remotely enable/disable Location Services for macOS devices using Hexnode UEM’s Execute Custom Script action.
Scripting language – Bash
File extension – .sh
How to enable Location Services on Mac?
1 2 3 |
sudo /usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled –bool true |
Execute this command and restart the device to enable Location Services.
What happens at the device end?
On restarting the device, Location Services will be enabled. It will not affect the existing location services setting of individual applications and services.
That is, the apps/services whose checkboxes had previously been marked will be allowed access. Further changes can be made by the admin user at the device end.
How to disable Location Services on Mac?
1 2 3 |
sudo /usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled –bool false |
Execute this command and restart the device to disable Location Services.
What happens at the device end?
On restarting the device, Location Services will be disabled. None of the apps/services will be given access to the service.
How to view the current status of Location Services?
1 |
sudo -u "_locationd" defaults -currentHost read "/var/db/locationd/Library/Preferences/ByHost/com.apple.locationd" |
Execute this command to check whether Location Services is currently enabled or not. The output can be viewed under the Action History tab of the device.