How to Find Linux Server Geographic Location in Terminal

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

4 Responses

  1. Jeff H Silverman says:

    There are many geoip lookup services. My issue with is that they don’t appear to do IIPv6. By way of contrast, has a comparable API and *will* do IPv4 and IPv6 addresses. They do require that you get an API key, but they have a development pricing level that’s free.

    [email protected]:/home/jeffs $ curl -4 -s "${API_KEY}" | jq ".ip" | sed -e s/\"//g

    [email protected]:/home/jeffs $ curl -6 -s "${API_KEY}" | jq ".ip" | sed -e s/\"//g

    Likewise, I can get the information about somebody else’s IPv4 or IPv6 address:

    [email protected]:/home/jeffs $ curl -4 -s "${API_KEY}&ip=" | jq ".latitude,.longitude" | awk -F": " '{ print substr($1,2,length($1)-2)}'

    [email protected]:/home/jeffs $ curl -6 -s "${API_KEY}&ip=" | jq ".latitude,.longitude" | awk -F": " '{ print substr($1,2,length($1)-2)}'

    I am filtering the outputs through sed to get rid of the ” characters.

    Bottom line is that there are many IP geolocation services. You should try several different ones, see what API you like best. Everything else in this article is a little bash-foo.

  2. bazio101 says:

    Nice tutorial.

    You can also find IP by using:

    # curl

    and if GeoIP is installed:

    # geoiplookup

    Gives you the country name and info about your ISP.

    If you specify location of GeoLiteCity.dat file:

    # geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat

    You get the rest (city and coordinates).

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.