Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

(Note the Mountain Lion update at end of question)

Some GUI apps use OS X location services, but I want to retrieve a Mac's physical location from the command line. This could be useful for running scripts, switching settings etc. The mechanism should be CoreLocation, not a Geo IP service (data too low-res, needs online connection).

Minimum requirement is output of longitude and latitude. Nice would be a number indicating the precision. Super nice: a geocoder that provides location names.

Update for Mountain Lion: The result of my 100 points bounty is: We have three working versions for OS X 10.8. Thanks to all involved!

WhereAmI (1.02)

paulgrav built a new binary that runs on 10.8 (download). This is my personal recommendation, because it’s so simple, and has the best error reporting.
Output style:

Latitude: 63.518321
Longitude: 3.431305
Accuracy (m): 65.000000
Timestamp: 04.01.13 18:20:13 MEZ

LocateMe (0.2)

Works if binary is moved to /Applications. Output style (linebroken for readability):

<+63.518321,+3.431305> +/- 65.00m (speed -1.00 mps / course -1.00)
@ 04.01.13 18:22:48 Mitteleuropäische Winterzeit


A summer 2014 version now supports single and continuous output of location data (see comment below). Output style:

<+51.91892126,+4.45120488> +/- 65.00m (speed -1.00 mps / course -1.00) @ 04.01.13 18:22:48 Mitteleuropäische Winterzeit
<+51.91902353,+4.45133598> +/- 65.00m (speed -1.00 mps / course -1.00) @ 04.01.13 18:26:17 Mitteleuropäische Winterzeit
<+51.91894650,+4.45124279> +/- 65.00m (speed -1.00 mps / course -1.00) @ 04.01.13 18:26:18 Mitteleuropäische Winterzeit
share|improve this question
Interesting question, but I don't believe their is a built in application that provides this data. From what I can gather, Apple uses data from Skyhook wireless (skyhookwireless.com) to locate there devices. Skyhook has a free API, so someone could theoretically write a very simple application to do this. If you'd prefer to steer clear of C, you could try to adapt the Loki API (loki.com) to fit your needs, from a Shell script. I tried to run their demo, but it needed to install a Chrome plugin. So, this may not be a viable answer. –  RLH Aug 9 '12 at 14:56
What kind of information would you like to see as output to a terminal geolocate program? –  MrDaniel Aug 9 '12 at 15:03
I updated the question regarding required output. –  myhd Aug 9 '12 at 16:52
@ RLH: Apple originally used Skyhook but now it uses its own internally built database. –  Richard Belisle Aug 9 '12 at 18:23
The URL for WhereAmI is now github.com/robmathers/WhereAmI (instead of robmathers.github.com/WhereAmI/.) –  TJ Luoma Jan 23 at 4:25

5 Answers 5

up vote 22 down vote accepted

vilmoskörte's answer appears to be a good one, but I took it upon myself to make a tool that does this for my own education. I put it on GitHub.


A simple command line tool. No options, just runs and outputs Lat/Long, accuracy in meters, and a timestamp. It will need OS X Location Services to be turned on (System Preferences > Security & Privacy), and permission to gather your location (OS X will prompt you on first run).

Direct Download Link (.zip)

share|improve this answer
That’s great - bonus for simplicity!! –  myhd Aug 14 '12 at 14:59
link's broken, raised a pull request with rob –  booyaa Aug 29 '13 at 6:20
@booyaa thanks for the prompting. Link broke a while ago when GitHub killed downloads and I messed up my account. It’s back now. –  robmathers Aug 29 '13 at 16:21

This already has been programmed, have a look at


share|improve this answer
very nice. cool option: -g … Generate a Google Map URL –  myhd Aug 14 '12 at 14:54
The author of the software has indicated that they are aware of the Mountain Lion problems and will look over the code to see if an easy fix is available. –  bmike Dec 29 '12 at 20:32

I'm the author of LocateMe, and I just discovered that I have to copy LocateMe into the /Applications folder for it to work in Mountain Lion. I'm not sure what I'd have to do to avoid that -- probably something about getting a cert, which I'm not likely to pursue anytime soon.

In the meantime, for LocateMe and probably the others, try copying them to /Applications and see if you have better luck.


share|improve this answer
I can confirm that works. –  markhunte Jan 2 '13 at 10:09

Those apps need to be signed with a developer certificate before they can authorise with the Core Location service. If you look in Console.app you can see the failed attempts to authorise:

31/12/2012 13:08:26.441 locationd[484]: Couldn't get information from PID 40084
31/12/2012 13:08:27.515 CoreLocationAgent[40086]: CodeSigningInforequest for pid=40084 

I’ve used my developer account to build and sign a new whereami binary. After you run it Mountain Lion will ask your permission to enable it to access location data.

share|improve this answer
This worked great for me in Mac 10.8.2 –  TJ Luoma Jan 1 '13 at 3:52

I'm the author of CoreLocationCLI, mentioned in the comments above. Just wanted to note that we have moved the project to this location:


Also, it now supports --once if you are only looking for a single output, rather than continuous output.

Lastly, there is a full binary on the project page as well if you would rather not compile it yourself. You will still need to authorize ("Would you like this app to be able to access your location") on the first app run.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.