check server geo location

How to Check Linux Server Location

Sometimes you may need to find the geo location of a remote Linux system using its IP address. In this article, we will learn how to do that using simple shell scripting and APIs. Every server has an IP address directly assigned by the network it is a part of. You can use two useful APIs and that allow you to easily get the city, state and country of an remote Linux server.

How to Check Linux Server Location

Here are the steps to get Linux server location from IP address.

1. Install cURL and jq

First we need to install cURL and jq tools. cURL is used to download location information from APIs and jq tool is used to convert the JSON data received from these APIs into readily usable format. So open terminal and run the following commands, depending on your system.

$ sudo apt install curl jq		#Ubuntu/Debian
$ sudo yum install curl jq		#CentOS/RHEL
$ sudo dnf install curl jq		#Fedora 22+
$ sudo zypper install curl jq		#openSUSE

2. Find Server’s IP address

This step is optional. If you already know the IP address of your remote Linux server, you can skip to the next step. Otherwise, you may need to run the following command from within the remote server (not the client) to find the remote server’s public IP address.

$ curl

Alternatively, you can Google ‘what is my IP’ from the remote server (not the client). Whichever system you run these commands from, it will show you the IP address of that system.

3. Get IP Location Data

Once you have the public IP address of remote server, you can use curl to make a request to ipvigilante API to get the location information about the IP address. Replace <your ip address> with your remote server’s public IP address.

$ curl<your ip address>

Here is a sample output in JSON format.

4. Automate Geo Location Checking

We will create a shell script to automatically get the public IP of remote server and check its location. Create a new file using a text editor.

$ vi

Add the following line to it.

curl -s$(curl -s | jq '.data.latitude, .data.longitude, .data.city_name, .data.country_name'

Save and close the file. In the above code, we we use curl command to make request to Instead of providing the IP address of remote server, we use another curl request to to get the remote server’s IP address. We pass the JSON output of the first curl command to jq utility and fetch latitude, longitude, city_name, country_name.

$ chmod +x

You can run the shell script from remote server using the following command.

$ ./

If you want to get other information from ipvigilante, you can modify the variables used in jq command.

In this article, we have learnt how to find Linux server location. It is very useful in case you need to find the geo location of remote Linux server. If you know that remote server’s public IP address you can easily send request to and get required data.

Also read:

How to Encrypt Drives Using LUKS in Linux
How to Limit Time & Memory of Processes in Linux
How to Use Yum History to Find Installed Package
What to Do After Installing Ubuntu
How to Fix No Route To Host SSH Error

Leave a Reply

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