How to Get Weather Details of a Location from Linux Command Line Using WTTR.IN

We’ve already discussed a utility called weather that lets you check weather information of any location from the Linux command line. While the application delivers what it promises, its output is nothing but a bunch of text that demands careful reading, and more importantly, you have to first install the tool on your system to get things working.

What if I said it’s possible to get weather information on terminal without actually installing any utility? Yes, that’s possible and WTTR.IN makes it possible. In this article we will discuss how to use this utility and some of the key features it provides.

So what exactly is wttr.in? It’s a web front end for a tool named Wego, a command line utility to get weather information. So given that wttr.in is a web-based utility, you don’t necessarily have to install it locally, as you can simply access it using cURL. And since it uses Wego at the back-end, the output produced is as though it was produced by a command line utility.

Like I said, there’s no need to install the wttr.in utility. However, you have to make sure that cURL is installed on your system. If it isn’t, you can install it by running the following command:

sudo apt-get install curl

That’s it. You can now use wttr.in to check weather information.

In its most basic form, you can use the wttr.in utility by running the following command:

curl wttr.in

The above command will get the information for your current location based on your IP address. When I tried this command I got the following output.

wttr-no-location-new

So, as you can see, wttr.in gives you well-formatted, detailed weather information for three days, breaking each day into four parts: Morning, Noon, Evening, and Night.

If you observe closely, the utility was not able to find my location (Chandigarh, India), so it displayed the weather information of Oymyakon in Russia, which is presumably the default location it uses in cases like this. I tried this command multiple times but remained out of luck.

If you encounter a similar situation, there are several alternative ways to get weather information for your location, such as by specifying the location name. As I am based in Chandigarh in India, this is how I passed on my location information to wttr.in:

curl wttr.in/"Chandigarh"

wttr-location

Note: If the location name contains spaces – like New York – it’s advisable to use quotes around the name. I use it all the time, as it’s a good practice in general.

Moving on, it’s also possible to get weather information for airports, something which you can do by using their 3-letter IATA codes. For example, the following command will get you weather information for John F. Kennedy International Airport:

curl wttr.in/JFK

wttr-airport

For a complete list of airports by IATA codes, head here.

Next up, you can also use domain names as a location specifier. For example, the following command will get you the weather information of the city that hosts the MTE server:

curl wttr.in/@maketecheasier.com

wttr_domain

What’s more, you can even use ZIP codes to get weather-related information. Here’s an example where I used a San Jose zip code:

curl wttr.in/95101

wttr-zipcode

By default, output produced by wttr.in is in SI (metric) units. However, If you’re in the US, where USCS is used by default, you can change the metric by adding a ‘?u’ at the end of the command. Here’s an example:

curl wttr.in/95101?u

wttr-uscs-metric

You can see that all the Celsius values were changed into values based on the Fahrenheit temperature scale.

The first – and obvious – advantage of wttr.in is that it’s web-based, meaning you don’t have to install it to use it. Secondly, the output it produces is comprehensive as well as visually appealing – like a GUI-based utility produced it. Thirdly, and most importantly, both command line pros as well as newbies can use it easily. This all adds up to plenty of reasons to give wttr.in a try.

Leave a Reply

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.