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

Spread the love

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.

WTTR.IN

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.

Installation and Setup

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.

Usage

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.

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"

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

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

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

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

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

Conclusion

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.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Himanshu Arora

Himanshu Arora is a freelance technical writer by profession but a software programmer and Linux researcher at heart. He covers software tutorials, reviews, tips/tricks, and more. Some of his articles have been featured on IBM developerworks, ComputerWorld, and in Linux Journal.

Comments (3)