How to look up the geographic location of an IP address from the command line

If you want to find out where a given IP address is physically located on earth, there are quite a few online GeoIP lookup services you can try (e.g. geoiptool.com). These online services are mostly powered by freely available GeoIP databases such as those from MaxMind. Besides using such web-based services, there are different ways to query the GeoIP databases, notably via the Linux command line. In this tutorial, I am going to describe how to geolocate an IP address from the command line in Linux.