{"id":8109,"date":"2021-07-10T12:31:34","date_gmt":"2021-07-10T12:31:34","guid":{"rendered":"https:\/\/linuxways.net\/?p=8109"},"modified":"2021-07-10T12:31:34","modified_gmt":"2021-07-10T12:31:34","slug":"how-to-find-linux-server-geographic-location-in-terminal","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-find-linux-server-geographic-location-in-terminal\/","title":{"rendered":"How to Find Linux Server Geographic Location in Terminal"},"content":{"rendered":"<p>Sometimes, you might need to find out the geographical location of a Linux server, more so a cloud server. Such information may include its IP address and Physical location in terms of Country, City, and coordinates ( Longitudes and Latitudes ). There are different ways of going about this and in this tutorial we will examine how to find your server\u2019s Geographic location.<\/p>\n<h2><strong>Prerequisites<\/strong><\/h2>\n<p>As you begin, be sure that curl is installed. We shall use it to make API requests later on in this guide. You can confirm its presence or installation by invoking<\/p>\n<pre><strong>$ curl --version<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"887\" height=\"266\" class=\"wp-image-8110\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-237.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-237.png 887w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-237-300x90.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-237-768x230.png 768w\" sizes=\"auto, (max-width: 887px) 100vw, 887px\" \/><\/strong><\/p>\n<h2><strong>Find the Public IP address of the server<\/strong><\/h2>\n<p>If you have the public IP address of the Linux server, that\u2019s fine. However, if you are currently logged in and would want to verify the server\u2019s public IP, you can do so by running the following <strong>curl<\/strong> command.<\/p>\n<pre><strong>$ curl https:\/\/ipinfo.io\/ip<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"721\" height=\"144\" class=\"wp-image-8111\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-238.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-238.png 721w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-238-300x60.png 300w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/strong><\/p>\n<p>Additionally, you can also invoke the curl command followed by the <strong>ifconfig.me<\/strong> tool that is used for displaying the public IP address on Linux systems.<\/p>\n<pre><strong>$ curl ifconfig.me<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"161\" class=\"wp-image-8112\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-239.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-239.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-239-300x66.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/strong><\/p>\n<h2><strong>Find the Geographical details of the server<\/strong><\/h2>\n<p>With the IP address in hand, you can now proceed to extract the precise Geographical details by sending API requests to <strong>ipinfo.io<\/strong> as shown. The <strong>ip-address <\/strong>is the public IP of the server.<\/p>\n<pre><strong>$ curl https:\/\/ipinfo.io\/ip-address<\/strong><\/pre>\n<p>The command yields a wealth of information in JSON format which includes the city, country, region, geolocation in terms of latitude and longitude, and the timezone where the server is situated.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"735\" height=\"319\" class=\"wp-image-8113\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-240.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-240.png 735w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-240-300x130.png 300w\" sizes=\"auto, (max-width: 735px) 100vw, 735px\" \/><\/strong><\/p>\n<p>If you just want to get the Country information alone, you can use the <strong>geoip<\/strong> lookup tool. This is available in repositories for major Linux distributions. You can install it as follows.<\/p>\n<h2>On CentOS\/RHEL<\/h2>\n<pre><strong>$ sudo yum install geoip<\/strong><\/pre>\n<h2>On Ubuntu \/ Linux Mint<\/h2>\n<pre><strong>$ sudo apt install geoip-bin<\/strong><\/pre>\n<h2>On Arch \/ Manjaro<\/h2>\n<pre><strong>$ sudo pacman -S geoip<\/strong><\/pre>\n<h2>On SUSE Linux<\/h2>\n<pre><strong>$ sudo zypper install geoip<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"790\" height=\"350\" class=\"wp-image-8114\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-241.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-241.png 790w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-241-300x133.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-241-768x340.png 768w\" sizes=\"auto, (max-width: 790px) 100vw, 790px\" \/><\/strong><\/p>\n<p>Once installed, you can run it as provided to obtain the country where your server is located.<\/p>\n<pre><strong>$ geoiplookup IP-address<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"724\" height=\"181\" class=\"wp-image-8115\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-242.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-242.png 724w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-242-300x75.png 300w\" sizes=\"auto, (max-width: 724px) 100vw, 724px\" \/><\/strong><\/p>\n<p>These are simple and handy ways that you can use to extract the geographical information of a Linux server on the command line.<\/p>","protected":false},"excerpt":{"rendered":"<p>Sometimes, you might need to find out the geographical location of a Linux server, more so a cloud server. Such information may include its IP address and Physical&hellip;<\/p>","protected":false},"author":1,"featured_media":8257,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[409,100],"class_list":["post-8109","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-server-geographic-location","tag-ubuntu-20-04"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/8109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=8109"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/8109\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/8257"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=8109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=8109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=8109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}