How to Access Weather Forecasts from Linux Command Line

While normal users tend to stay away from the Linux command line for obvious reasons, power users are the complete opposite, which means that they are always looking for good command line alternatives to GUI-based software they use, be it downloading a file from the Internet, sending a tweet, etc.

But did you know you can also check weather information from the Linux command line? It can be done by using the weather command. In this article, we will discuss the basics of the command along with the features it provides.

The weather utility is intended to provide quick access to current weather conditions and forecasts. Presently it is capable of returning data for localities throughout the USA and some select locations globally by retrieving and formatting decoded METARs (Meteorological Aerodrome Reports) from NOAA (the USA National Oceanic and Atmospheric Administration) and forecasts/alerts from NWS (the USA National Weather Service).

Users of a Debian-based Linux distribution like Ubuntu can download and install the weather command using the following command:

sudo apt-get install weather-util

Alternatively, you can also download its source and install it manually.

Here are some examples of how the weather command can be used:

Get weather information at a particular location

You can check weather at a particular location by passing its name as a command line argument. For example, to get weather information from the city of San Jose (California), run the following command:

weather "San Jose"

Here’s the result:

Searching via name...
[using result San Jose, CA]
Current conditions at San Jose / Reid / Hillv, CA
Last updated Dec 14, 2014 - 12:49 AM EST / 2014.12.14 0549 UTC
  Temperature: 48 F (9 C)
  Relative Humidity: 93%
  Wind: Variable at 6 MPH (5 KT)
  Sky conditions: clear

Also, even if there’s an ambiguity in the name supplied by you, the utility gives you a list of available options to choose from:

weather-ambiguity-options

Alternatively, you can also use the Federal Information Processing Standard (FIPS) code of a place to get its current weather conditions. For example, to get San Jose’s weather information, you can use its FIPS code 0668000 in the following way:

weather fips0668000

and its result:

Searching via FIPS...
[caching result San Jose, CA]
Current conditions at San Jose / Reid / Hillv, CA
Last updated Dec 14, 2014 - 12:49 AM EST / 2014.12.14 0549 UTC
  Temperature: 48 F (9 C)
  Relative Humidity: 93%
  Wind: Variable at 6 MPH (5 KT)
  Sky conditions: clear

Get local forecast using the -f option

Aside from current weather conditions, you can also get local forecasts using the -f command line option. Here is an example:

weather -f "San Jose city"

weather-local-forecast

Display information related to specific weather conditions

If you want to only display information related to specific weather conditions like temperature, wind, and more, you can do that using the --headers command line option. For example, the following command only displays wind related information:

weather fips0668000 --headers=wind
Current conditions at San Jose / Reid / Hillv, CA
Last updated Dec 14, 2014 - 12:49 AM EST / 2014.12.14 0549 UTC
  Wind: Variable at 6 MPH (5 KT)

Get weather information at airports

You can check weather at airports using the (International Air Transport Association) IATA code, or the ICAO (International Civil Aviation Organization) code. For this, all you have to do is to run the weather utility along with an IATA or ICAO code as a command line argument.

For example, here is an example of the weather command that uses ICAO code to display weather information at New Delhi airport in India:

weather VIDP
Searching via station...
[caching result New Delhi / Palam, India]
Current conditions at New Delhi / Palam, India (VIDP) 28-34N 077-07E 233M
Last updated Dec 14, 2014 - 04:00 AM EST / 2014.12.14 0900 UTC
  Temperature: 59 F (15 C)
  Relative Humidity: 100%
  Wind: from the ESE (110 degrees) at 5 MPH (4 KT)
  Weather: mist
  Sky conditions: mostly cloudy

And the following command uses IATA code to display weather information at Daytona Beach International:

weather DAB
Searching via airport...
[caching result Daytona Beach International, FL, United States]
Current conditions at Daytona Beach International, FL
Last updated Dec 14, 2014 - 03:53 AM EST / 2014.12.14 0853 UTC
  Temperature: 44.1 F (6.7 C)
  Relative Humidity: 85%
  Wind: from the WSW (250 degrees) at 3 MPH (3 KT)
  Sky conditions: clear

For more options, go through the weather command’s man page (http://manpages.ubuntu.com/manpages/raring/man1/weather.1.html).

The weather command is a useful utility that provides a host of options, and is aimed at power users or those who require such information to be automatically added to their reports, although that doesn’t mean an average user can’t use it.

Have you ever used the weather command or a similar utility? How was your experience? Share your thoughts in the comments below.

Image credit: Cloud, forecast, grey, rain, sun, weather icon