Find out how to Discover Linux Server Geographic Location in Terminal


Get real time updates directly on you device, subscribe now.

On this article, we are going to present you tips on how to discover the IP tackle geographic location of a distant Linux system utilizing open APIs and a easy bash script from the command line.

On the web, every server has a public-facing IP tackle, which is assigned on to the server or through a router that sends community visitors to that server.

IP addresses present a simple method to observe the situation of the server on the planet through the use of two helpful APIs supplied by and to get the metropolis, state, and nation related with a server.

Set up Curl and jq

To get the IP tackle geographic location of the server, we have to set up curl command line downloader and jq command-line device to course of the JSON information from the geolocation APIs.

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

Install Curl and JQ in LinuxInstall Curl and JQ in Linux

Set up Curl and JQ in Linux

Discover the Server’s Public IP Handle

To get the server’s public IP tackle, use the next curl command to make an API request to in your terminal as proven.

$ curl

Get Linux Server IP AddressGet Linux Server IP Address

Get Linux Server IP Handle

Get IP Location Knowledge From The API

After getting acquired the server public IP tackle, now you can make a request to‘s API to fetch the geolocation information utilizing the next command. Make sure that to switch with the server’s public IP.

$ curl

Get Linux IP Geo LocationGet Linux IP Geo Location

Get Linux IP Geo Location

That is the information we get from the above command.

Server Location DetailsServer Location Details

Server Location Particulars

Automate API Name utilizing Bash Script

Now to automate the API course of, we are going to create a script known as (you possibly can title it something you need) utilizing any of your favourite command line editors.

$ vim

Then copy and paste the next lengthy command in it.

curl -s$(curl -s | jq ‘.information.latitude, .information.longitude, .information.city_name, .information.country_name’

Save the file and make the script executable with the next command.

$ chmod +x

Lastly, run the script to get your Linux IP geographical location as proven within the following screenshot.

$ ./

Find Linux Server GeolocationFind Linux Server Geolocation

Discover Linux Server Geolocation

The above script reveals the metropolis and nation title together with the approximate latitude and longitude coordinates.

Alternatively, you too can run the above command with out saving it in a script as proven.

$ curl -s$(curl -s | jq ‘.information.latitude, .information.longitude, .information.city_name, .information.country_name’

Get Linux Server Location DetailsGet Linux Server Location Details

Get Linux Server Location Particulars

You may additionally wish to learn these following associated articles:

four Methods to Discover Server Public IP Handle in Linux Terminal
Discover Out All Stay Hosts IP Addresses Related on Community in Linux
Discover Prime 10 IP Addresses Accessing Your Apache Internet Server

That’s it for now! On this quick article, we’ve proven tips on how to get your Linux IP geographic location from the terminal utilizing the curl and jq instructions. Share your ideas with us or ask any questions through the suggestions kind beneath.

Source link

Leave A Reply

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More