How To Get Your Geolocation From Commandline In Linux

Get Your Geolocation From Commandline In Linux

This brief tutorial will walk you through how to get your geolocation from commandline in Linux. This could be useful if you wanted to know the location of your VPS or remote servers. A fellow Linux user Rafael Rinaldi has created a handy tool called “whereami” to find out the geolocation information using from the commandline. Please note that some hosting providers might have hidden their server’s exact place, or faked it due to security reasons. In such cases, this tool won’t help.

Now, let us get started to find out the geolocation of the Linux system from commandline using whereami utility.

Get Your Geolocation From Commandline In Linux

Install whereami

Installing ‘whereami’ tool is fairly simple and straight-forward. You need to install npm, a javascript package manager first.

To install npm on RPM based systems such as RHEL, CentOS, Fedora, run the following commands:

sudo yum install epel-release
sudo yum install npm


sudo dnf install epel-release
sudo dnf install npm

On Debian, Ubuntu, Linux Mint, run:

sudo apt-get install npm

On Arch Linux and its derivatives:

sudo pacman -S npm


sudo zypper install npm

Once npm installed, run the following command to install “whereami” tool.

npm install -g @rafaelrinaldi/whereami

You will get an output something like below.

/usr/bin/whereami -> /usr/lib/node_modules/@rafaelrinaldi/whereami/bin/whereami
└─┬ @rafaelrinaldi/[email protected] 
 ├─┬ [email protected] 
 │ ├─┬ [email protected] 
 │ │ └── [email protected] 
 │ ├── [email protected] 
 │ ├── [email protected] 
 │ ├── [email protected] 
 │ ├── [email protected] 
 │ ├── [email protected] 
 │ ├── [email protected] 
 │ ├── [email protected] 
 │ ├── [email protected] 
 │ ├── [email protected] 
 │ └─┬ [email protected] 
 │ └── [email protected] 
 ├─┬ [email protected] 
 │ └─┬ [email protected] 
 │ ├── [email protected] 
 │ └─┬ [email protected] 
 │ └─┬ [email protected] 
 │ ├── [email protected] 
 │ └── [email protected] 
 ├── [email protected] 
 ├─┬ [email protected] 
 │ └── [email protected] 
 └── [email protected]

Find Your Geolocation

Now, it’s play time. To know your location, simply run:


Sample output would be:


As you see in the above output, It displays the latitude (11.1), and longitude (77.35) of my location.

I don’t understand, can I have a human-readable format? Of course, you can! Add –f human switch with whereami command like below.

whereami --f human

Here is my output:

Tiruppur, Tamil Nadu, India

I wouldn’t say this is an accurate result, but it was very close to my actual location.

I need more details, can I have that too? Yes! Display the raw result that contains the public IP address, country code, zip code, metro code time zone etc., using the following command:

whereami -r

Sample output:

{"ip":"","country_code":"IN","country_name":"India","region_code":"TN","region_name":"Tamil Nadu","city":"Tiruppur","zip_code":"641603","time_zone":"Asia/Kolkata","latitude":11.1,"longitude":77.35,"metro_code":0}

To know more details about whereami command, run:


whereami -help

Sample output:

Usage: whereami [OPTIONS]

Get your geolocation information using from the CLI

 $ whereami

$ whereami --f human
 San Francisco, CA, United States

 -v --version Display current software version
 -h --help Display help and usage details
 -f --format Output format (either human, json or sexagesimal)
 -r --raw Output raw data from

I am pretty sure there could be other tools and ways to find out the geolocation. D you know any other methods? Please enlighten me in the comment section below.

Hope this helps. I will be soon here with another useful guide. If you find guide useful, please share it on your social networks and support OSTechNix.

Happy weekend! Cheers!!


Thanks for stopping by!

How can I benefit from this blog:

Have a Good day!!

You may also like...

6 Responses

  1. Warren L Shafor says:

    How could I get this to work on OS X?

  2. SpecialEd says:

    When I run whereami I get the following error message:

    Can’t write PID file to /var/run/whereami.started.20241 at /usr/sbin/whereami line 229.

    Any suggestions?

Leave a Reply

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.