weather: check weather conditions and forecasts on the command line

October 4th, 2007 edited by Tincho

Article submitted by Dann Frazier. We are running out of articles ! Please help DPOTD and submit good articles about software you like !

weather, provided by the weather-util package, is a simple command line tool that lets you check current conditions and forecasts. It uses METAR data that it fetches from the the National Oceanic and Atmospheric Administration and forecasts from the National Weather Service. The documentation says it’s limited to providing information for the United States, but in fact, METAR data is available for stations all around the world. The forecast won’t be available, though.

Many locations are already pre-configured in the package’s /etc/weatherrc. If your location is already defined, you only need to look up the alias to begin using it. For example, /etc/weatherrc provides the following entry for Albuquerque, New Mexico:

City = Albuquerque
St = NM

The alias for Albuquerque is ‘ABQ’. Therefore, weather ABQ will show you the current conditions for Albuquerque:

$ weather ABQ
Current conditions at Albuquerque International Airport (KABQ)
Last updated Sep 26, 2007 - 04:56 PM EDT / 2007.09.26 2056 UTC
  Wind: from the ESE (120 degrees) at 3 MPH (3 KT)
  Sky conditions: mostly clear
  Temperature: 77.0 F (25.0 C)
  Relative Humidity: 15%

weather -f ABQ will include a local forecast:

$ weather -f ABQ
Current conditions at Albuquerque International Airport (KABQ)
Last updated Sep 26, 2007 - 04:56 PM EDT / 2007.09.26 2056 UTC
  Wind: from the ESE (120 degrees) at 3 MPH (3 KT)
  Sky conditions: mostly clear
  Temperature: 77.0 F (25.0 C)
  Relative Humidity: 15%
City Forecast for Albuquerque, NM
Issued Wednesday afternoon - Sep 26, 2007
  Wednesday night... Low 52, 0% chance of precipitation.
  Thursday... Sunny, high 81, 0% chance of precipitation.
  Thursday night... Low 54, 5% chance of precipitation.
  Friday... Partly cloudy, high 80.
  Friday night... Low 56.

You can add new locations to this file directly, or to per-user ~/.weatherrc files. You can also define a default location by adding a stanza with an alias named “default”. For example, here’s the contents of my ~/.weatherrc file:

City = denver
Forecast = True
St = CO

City and St (state) are used for obtaining forecasts, while ID is used for retrieving current conditions. I use this configuration to tell weather to retrieve forecasts from Denver, CO but to use a station that is closer to me for obtaining current conditions. Note that if you do not specify a location and have no alias named ‘default’, weather will fall back to a hard-coded default of Raleigh, NC.

Knowing what information weather uses to obtain the data you request is important when defining your own configurations. For example, say I want to know the current conditions for Lubbock, TX and I run the following command:

$ weather -o --city=Lubbock --st=TX
Current conditions at Fort Collins-Loveland Municipal Airport (KFNL)
Last updated Sep 26, 2007 - 05:55 PM EDT / 2007.09.26 2155 UTC
  Wind: from the ENE (070 degrees) at 5 MPH (4 KT)
  Sky conditions: clear
  Temperature: 71 F (22 C)
  Relative Humidity: 23%

(The -o tells weather to omit the forecast). Notice that weather gave me the current conditions for my ‘default’ alias, not for Lubbock. This is because weather looks up current conditions by station ID, not by city/state. If I pass the station ID instead, I’ll get the information I was looking for:

$ weather -o --id=KLBB
Current conditions at Lubbock International Airport (KLBB)
Last updated Sep 26, 2007 - 05:53 PM EDT / 2007.09.26 2153 UTC
  Wind: from the S (170 degrees) at 9 MPH (8 KT) gusting to 18 MPH (16 KT)
  Sky conditions: mostly cloudy
  Weather: Cumulonimbus clouds, towering cumulus clouds observed
  Temperature: 86.0 F (30.0 C)
  Relative Humidity: 38%

Being a command-line tool, weather lends itself to various automatic processes. For example, you might want to cancel your weekly bicycle pub crawl if the forecast shows a high chance of rain:

$ cat /etc/cron.weekly/pub-reminder

set -e

if weather -f | egrep -q '(100)|([5-9][0-9])% chance of precipitation’; then
 mailx -s ‘Cancellation’ $PUBCRAWLEES < ~/pub-crawl-cancelled
 mailx -s 'Get on your bike' $PUBCRAWLEES < ~/pub-crawl-is-a-go

Of course, I’d just recommend a rain jacket.

weather is provided by the weather-util package and is available in Debian ‘etch’, testing and unstable, and Ubuntu ‘edgy’, ‘feisty’ and ‘gutsy’.

Edited to add: for international weather station ids, users can look on this US government website. Thanks hideokuze for the info.

Posted in Debian, Ubuntu |

14 Responses

  1. Juanmi Says:


    Every day DEBIAN surprises to me.

    Thanks Debaday ;-)

  2. hideokuze Says:

    For international weather station ids, users can look on this US government website:

    Perhaps the submitter should add that bit of info to the article, since the original weatherrc only has North America stations and therefore would be deemed useless on first glance by other international readers.

  3. tata Says:

    Good job reviewing “weather”. This is a nice utility.
    I love the fact that it is a cli app, unlike gkrellm’s weather plugin which can be rather bothersome. Another nice thing about “weather” is I love that it displays in both imperial and metric.

  4. Karl Says:

    kde users have had this for a long time as kweather.. its a applet on the task bar with an icon indicating the current conditions. — clicking on it brings you to the complete data from your local airport…

    Weather Report - Topeka, Forbes Field
    Last updated on Friday 05 October 2007 05:53 pm
    Clear skies
    Wind gusts up to 26 MPH
    Dew Point:
    Air Pressure:
    29.90″ Hg
    Rel. Humidity:
    Wind Speed:
    17 MPH S
    Heat Index:
    07:22 am
    06:59 pm

  5. Clair Says:

    I didn’t know this! Neat package from Debian. Must check it out soon! :D

  6. SamuraiPenguin Says:

    I can’t help but mention… without the -f, you could just open a window… :) I have to remind myself every once in awhile that there’s a world outside of my bash prompt.

  7. Juan Says:

    erm… gweather on gnome

  8. thinway Says:

    Another great utility is Weather Wallpaper. The weather info as a wallpaper of our desktops.

  9. thinway Says:

    Weather Wallpaper Link

  10. Evil Dick Says:

    Oops! I clicked way too low on “Rate this article”. It was an accident, 2 or something way too low. I would give this article a very high score. I have never rated an article here before and was not aware that clicking on the stars actually cause a rating vote.

  11. Volker Says:

    KWeather is nearly useless. Just gives the local conditions. Might as well step out the front door.
    This is much more useful since it gives the forecast.

  12. Kamaraju Kusumanchi Says:

    For locations which are not defined in /etc/weatherrc, you can get the required info on weather stations and their respective codes from

  13. wolfo Says:

    only works if the city has a 4-letter airport code :( the 5-number code listed on ( don’t work. is there maybe a way to manipulate to make this work?

  14. weather-util, look-up weather info through the terminal « exper1ment1ng Says:

    [...] idea was taken from here and is just adjusted for the Greek weather. Unfortunately, there is no capability for weather [...]