Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

It seems like there is a package called geoclue which uses Mozilla's location service to lookup wireless access points and their known location, but there doesn't seem to be a command line interface for this. Is there another way to do it? Any clever hacks?

share|improve this question
Maybe this can help:… – Parto Mar 6 '14 at 9:28
Do you have a GPS device attached on on your USB ports? – Radu Rădeanu Mar 6 '14 at 15:09
@AvatarParto that answer only talks about the library there is no command line app for it. – Mike McKay Mar 7 '14 at 6:19
@RaduRădeanu I don't have a GPS device. I want to use the names of Wifi access points and a database of locations, like how OSX does it (and google also): – Mike McKay Mar 7 '14 at 6:20
@MikeMcKay Yah, that's why I wrote 'Maybe this can help'. It's like more info or something. – Parto Mar 7 '14 at 6:26

4 Answers 4

If you want IP based lookup... (but you'll have to fix the HTML formatting of the output)

wget && egrep "IP Location|City|Latitude|Longitude" my_ip_address.php
share|improve this answer

To get your location by IP you can use:

curl -s | sed -n 's|.*> *\(.*\)</h3>|\1|p'

To get your coordinates by IP you can use:

curl -s | sed -n 's/.*Coordinates \(.*\)<.*/\1/p'
share|improve this answer
Any reason for -1? – Radu Rădeanu Mar 7 '14 at 14:05
guess he is asking about Mozilla's location service to lookup wireless access points and their known location – Waqas Mar 7 '14 at 14:08

Here's my own best answer, which tries out all of the different geoclue providers available in Ubuntu:

apt-get install geoclue geoclue-ubuntu-geoip python-geoclue geoclue-yahoo geoclue-plazes geoclue-localnet geoclue-gypsy

echo "#!/usr/bin/env python

import Geoclue

providers = 'Gypsy, Hostip, Localnet, Plazes, Skyhook, Yahoo, Ubuntu GeoIP'
providers = providers.split(', ')
for provider in providers:

  POS_PROVIDER = provider

  location = Geoclue.DiscoverLocation()
  position = location.get_location_info()

  print provider
  print position['latitude']
  print position['longitude']
" >


This results in:

org.freedesktop.DBus.GLib.UnmappedError.GeoclueErrorQuark.Code1: Could not understand reply from server
org.freedesktop.DBus.GLib.UnmappedError.GeoclueErrorQuark.Code1: Couldn't parse response from web service
Ubuntu GeoIP

Which is a big step forward, but it seems that all of the providers are using IP based lookup, and my VPN totally throws that off. Seems like there should be a provider that only uses wifi access points, but I haven't found it yet.

share|improve this answer

There is a workaround that use your IP and find your location based to your Real IP.

first install lnyx

sudo apt-get install lynx-cur

Now the command is:

lynx -dump$1|grep address|egrep 'city|state|country'|awk '{print $3,$4,$5,$6,$7,$8}'|sed 's\ip address flag \\'|sed 's\My\\'
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.