I want to find the current weather of a particular city or my location from terminal. Is there any command-line weather app?
15 Answers
Simply enter the following in a terminal:
curl wttr.in
And will get your location from /etc/timezone
. Otherwise curl wttr.in/your_location
. For example, for Tehran:
curl wttr.in/tehran
Which gives you:
You can also compare two cities:
diff -Naur <(curl -s http://wttr.in/london ) <(curl -s http://wttr.in/new-york )

- 15,657

- 1,886
Search for your city at http://www.accuweather.com and replace the URL in the following script with the URL for your city:
#!/bin/sh
URL='http://www.accuweather.com/en/de/berlin/10178/weather-forecast/178087'
wget -q -O- "$URL" | awk -F\' '/acm_RecentLocationsCarousel\.push/{print $2": "$16", "$12"°" }'| head -1
Sample output:
Berlin, Germany: Foggy, 1°

- 87,389
-
-
In the source html, I see
acm_RecentLocationsCarousel.push({name:"Berlin, Germany", daypart:'day', href:'/en/de/berlin/10178/weather-forecast/178087', icon:'i-6-l', bg:'c', temp:'0', realfeel:'-6', text:"Mostly cloudy"});
. Using your code, theawk
field separator is ' ' (space). Is$12
(temperature) the 12th column? – Timo Dec 10 '17 at 08:41 -
My fault, the
awk
separator is'
. The api uses 2 numbers, the first one is thepostleitzahl
or zipcode. The second seems to be an api code number – Timo Dec 10 '17 at 08:51 -
4
Here's a great semi-graphical command line utility written in Go:
https://github.com/schachmat/wego/
You'll need to install Go and setup some API stuff, but the instructions are there. Here's a sample pic:

- 309
-
5This is being publicly hosted now - with IP address to region mapping. Try: curl -4 http://wttr.in – jschrab Feb 24 '16 at 21:56
-
2
-
1Metric units are also available on the publicly hosted version, like so:
curl wttr.in/Helsinki?m
– Ville Sep 30 '19 at 20:13 -
If you need metric, don't forget to escape the question mark like this
curl wrrt.in/Helsinki\?m
or place the URL in single quotes like thiscurl 'wttr.in/Helsinki?m'
– mchid Dec 22 '20 at 02:22
I have got one more way .
Open your .bashrc
file and then paste this code at the bottom
weather(){ curl -s "http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=${@:-<YOURZIPORLOCATION>}"|perl -ne '/<title>([^<]+)/&&printf "%s: ",$1;/<fcttext>([^<]+)/&&print $1,"\n"';}
Then save & close your .bashrc
file.
now type bash
to update the file.
then type
weather <location name>
for example
august@august-OEM:~$ weather guntur
December 14, 2013: Clear. High 31&deg;C (87&deg;F). Winds 0 kph North
December 15, 2013: Clear. High 29&deg;C (84&deg;F). Winds 10 kph NNW
December 16, 2013: Clear. High 31&deg;C (87&deg;F). Winds 10 kph North
December 17, 2013: Clear. High 29&deg;C (84&deg;F). Winds 7 kph ENE
December 18, 2013: Scattered Clouds. High 29&deg;C (84&deg;F). Winds 3 kph ENE
December 19, 2013: Scattered Clouds. High 29&deg;C (84&deg;F). Winds 3 kph ENE

- 102,391
- 106
- 255
- 328
-
1
-
This no longer works, the last dates it shows is from May 2015 (for Cape Town, South Africa at least). Closer examination of the xml output reveals the txt_forecast parent has not been updated since May 2015 while the simpleforecast element seems to have the latest data. – Zahir J Dec 27 '16 at 22:12
-
-
-
When I replace
YOUZIPORLOCATION
with$1
and pass20001
(Washington, DC zipcode), I get lines that look unformatted likeToday: Mostly sunny and breezy. Highs in the upper 30s. Northwest winds 20 to 25 mph with gusts up to 45 mph.
When I use"washington.dc"
, I get table outputMay 4, 2015: Clear. High 32&deg;C (89&deg;F). Winds 43 kph East
. Any idea why the difference? – blalterman Jan 10 '19 at 13:47 -
-
1I spoke too soon. The api is no longer free and there once was the option to apply for a free key for limited use but this is no longer the case. – mchid Dec 22 '20 at 02:16
ansiweather
AnsiWeather is a Shell script for displaying the current weather conditions in your terminal, with support for ANSI colors and Unicode symbols. Weather data comes from the OpenWeatherMap free weather API.
sudo apt-get install ansiweather
ansiweather -l London,GB -f 3
London forecast => Sat Jan 13: 7/2 °C ☔ - Sun Jan 14: 4/1 °C ☔ - Mon Jan 15: 9/6 °C ☔

- 101
Another a program that comes pre-installed with Ubuntu called inxi
will give you all types of stats on your computer as well as a weather output.
command: inxi --help
command: inxi -w
Conditions: 82 F (28 C) - Clear Time: May 13, 10:52 AM CDT
command: inxi -wxxx
Conditions: 82 F (28 C) - Clear Wind: From the SW at 13 MPH Humidity: 60%
Pressure: 29.99 in (1016 mb) Heat Index: 84 F (29 C)
Location: city (USA) Altitude: 185 m
Time: May 13, 10:52 AM CDT (America/Chicago) Observation Time: May 13, 9:54 AM CDT

- 5,268
- 1
- 48
- 59

- 81
- 1
- 2
-
1Seems that inxi is not part of ubuntu, as of 10.04, but can be installed with
sudo apt install inxi
– Starbuck Nov 28 '18 at 23:35 -
Yes,
inxi
is available but you need to enable the universe repository first. – mchid Mar 17 '19 at 07:17
First you need to install the weather-util package, to do that just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:
sudo apt-get install weather-util
You’ll need your local weather code.
After installation you can run weather -i <code>
. The code you get from the link above. For a list of available options, you can run weather
Weather info

- 107,631
-
1it shows
Last updated Dec 11, 2013 - 07:00 AM EST / 2013.12.11 1200 UTC Temperature: 86 F (30 C)
.is there no way to know the current weather. – Avinash Raj Dec 13 '13 at 17:13 -
Depending on your location that could be the current info that's available. – Mitch Dec 13 '13 at 17:15
-
1I just tried this and discovered that it is easier to use now:
weather YOURLOCATIONNAME
It searches for your location then and provides possibly multiple results. From these you can read the station identifier which you can use as argument to fetch your weather informations from – Nicolas Mar 22 '16 at 23:05 -
It looks like the service it depends on has been discontinued. I just installed version 2.0, and
weather LAX
(which should show the weather for Los Angeles International Airport) shows a 404 error for http://weather.noaa.gov/pub/data/observations/metar/decoded/KNKX.TXT – Keith Thompson Aug 27 '16 at 20:08 -
1That particular data file has moved from here to here. It should be possible to update the data files, changing each occurrence of
http://weather.noaa.gov/pub/data
tohttp://tgftp.nws.noaa.gov/data
. UPDATE: Looks like they've already fixed it in version 2.1, which you can get from the project site. – Keith Thompson Jan 31 '17 at 03:08 -
1Users outside of the US should read
weather-util
s description though: "[...] providing data for localities throughout the United States of America and some select locations globally [...]" – domsson Jan 13 '18 at 16:09
Try using
telnet rainmaker.wunderground.com
Meteogram of all mayor cities in the world
finger city_name@graph.no
$ finger cologne@graph.no
-= Meteogram for germany/north_rhine-westphalia/cologne =-
'C Rain
16
15 ^^^
14 ======^^^ ^^^
13 === ^^^===^^^===
12 =========
11 === ====--
10 ====== ---
9=====| --- 3 mm
8 | | 2 mm
7 | | | | | | | | | | | | | | 1 mm
_08_09_10_11_12_13_14_15_16_17_18 19 20 21 22 23 00 01 02 03 04 05 Hour
SE SE SE SE SE SW SW W W W W SW W W W W W NW NW NW N N Wind dir.
5 5 5 5 4 4 5 6 6 6 5 5 5 4 4 5 5 5 4 3 3 3 Wind(mps)
Legend left axis: - Sunny ^ Scattered = Clouded =V= Thunder # Fog
Legend right axis: | Rain ! Sleet * Snow
[Weather forecast from yr.no, delivered by the Norwegian Meteorological Institute and the NRK.]
Adding ~$(tput cols)
automatically adapts the graph width to the number of columns available in the shell. The forecast will look further into the future on wide shells.
$ finger cologne~$(tput cols)@graph.no
Here is further information about how to use it:
$ finger help@graph.no
yr.no is having technical problems, or you specified an unknown location.
Usage:
- finger <city name>@graph.no (world weather forecast, no spaces)
Example: finger newyork@graph.no
Advanced usage:
finger o:<city name>@graph.no (a one-line forecast)
Example: finger o:newyork@graph.no
finger ^<city name>@graph.no (Imperial units)
Example: finger ^newyork@graph.no
finger <city name>+5@graph.no (forecast from 5 hrs ahead in time (max:26))
Example: finger northpole+5@graph.no
finger <city name>~160@graph.no (set screen width)
Example: finger southpole~160@graph.no
finger <city name>%2@graph.no (forecast for every second hour [Norway])
Example: finger oslo%2@graph.no
finger <post code>@graph.no (norwegian weather forecast)
Example: finger 0458@graph.no
Other:
- finger news@graph.no (latest headlines from NRK)
- finger time@graph.no (server local time)
- finger date@graph.no (server local date)
- finger about@graph.no (contact information)
International names comes from http://fil.nrk.no/yr/viktigestader/verda.txt.
The story behind this from the developer.

- 5,268
- 1
- 48
- 59
If you are familiar with ICAO station names and METAR weather information from an airport.
sudo apt install metar
and check your preferable airport to get the data from https://www.world-airport-codes.com/ Example for Tokyo International airport/ Haneda = RJTT
metar -d rjtt
Sample output
RJTT 302000Z 34009KT 9999 FEW030 BKN050 14/08 Q1025 NOSIG
Station : RJTT
Day : 30
Time : 20:00 UTC
Wind direction: 440 (NNE)
Wind speed : 9 KT
Wind gust : 9 KT
Visibility : 9999 M
Temperature : 14 C
Dewpoint : 8 C
Pressure : 1025 hPa
Clouds : FEW at 3000 ft
BRK at 5000 ft
Phenomena :
Unlike weather
command, this doesn't understand name of cities or countries. Instead of that feature, this can load quicker and multiple places at once.

- 1,379
You can compare cities using:
diff -Naur <(curl -s http://wttr.in/london ) <(curl -s http://wttr.in/new-york )
as illustrated in the top-voted answer. wttr.in
also makes a great "splash" screen every time you open the terminal. Do this by adding it to your ~/.bashrc
file. I've done that to include Weather, Date, Time and Distribution information as detailed in this answer: How can I get this terminal splash screen?
Sorry I was in Ubuntu in Windows 10 WSL for Spring 2018 updates when I captured this image. Promise I'll boot back into Ubuntu in Linux soon.

- 102,282
I have got one more way .
Open your .bashrc file and then paste this code at the bottom
test -f ~/.wttr.in || curl -sk wttr.in -o ~/.wttr.in
find ~ -maxdepth 1 -name .wttr.in -cmin +5 -exec curl -sk wttr.in -o ~/.wttr.in \;
head -7 ~/.wttr.in | tail -5
W(){ find ~ -maxdepth 1 -name .wttr.in -cmin +5 -exec curl -sk wttr.in -o ~/.wttr.in \;; head -27 ~/.wttr.in; }
Save & close your .bashrc
file and run the following command to update bash:
. .bashrc
then type W
upper case
-
-
-
2You don't have to relogin if you "source" your
.bashrc
file. You can run:source .bashrc
or you can run this instead:. .bashrc
– mchid Jan 27 '19 at 03:59
For even shorter weather output openweathermap.org provides weather data in json format.
The filds from the JSON can then be obtained with a JSON parser like jq i.e..
I wrote a q&d weather-fetch script, wich gets the current temperature, icon and description of weather, then stores a unicode symbol corresponding to the icon and outputs it like
☂ 6°C
I regularly update via cronjob and then use the output in my tray status.
An API-key is needed for openweathermap - you may send 1000 requests free of charge per day.
The JSON contains further fields, i.e. forecast data, wind etc. – you can parse them, too, if you want. A description of the API can be found at https://openweathermap.org/current#one .
Unfortunatly some weather symbols are not represented in the Ubuntufont… feel free to adjust.
Here's my script. Change location if you don't life in Hamburg,DE and replace dummy value with your API-key. Depends on curl and jq.
#!/usr/bin/env sh
#☁☂☔❄❅❆☃ ☀☁☂⚡⚐☼⛅☇☈☾
#settings - adjust
APIKEY="DUMMY"
LAT="53.618814544576594"
LON="10.131139271164836"
#build query url
QUERY="https://api.openweathermap.org/data/2.5/weather?lat="$LAT"&lon="$LON"&appid="$APIKEY"&units=metric"
write json to variable
WEATHER_JSON=$(curl -Ls "$QUERY")
if [ $? -ne 0 ]
then
exit 0
fi
get fields from xml via xmllint | xargs for trimming
weather description
WEATHER_TEXT=$(jq -r '.weather | .[0] | .description' - <<<"$WEATHER_JSON" | xargs);
WEATHER_ICON_CODE=$(jq -r '.weather | .[0] | .icon' - <<<"$WEATHER_JSON" | xargs);
temperature
WEATHER_TEMPERATURE=$(jq -r '.main | .temp' - <<<"$WEATHER_JSON" | cut -d '.' -f 1 | xargs);
set $WEATHER_SYMBOL according to $WEATHER_TEXT
if [ "$WEATHER_ICON_CODE" == "01d" ]; then WEATHER_SYMBOL="☼"; elif [ "$WEATHER_ICON_CODE" == "01n" ]; then WEATHER_SYMBOL="☾";
elif [ "$WEATHER_ICON_CODE" == "02d" ]; then WEATHER_SYMBOL="⛅";elif [ "$WEATHER_ICON_CODE" == "02n" ]; then WEATHER_SYMBOL="☁";
elif [ "$WEATHER_ICON_CODE" == "03d" ]; then WEATHER_SYMBOL="☁"; elif [ "$WEATHER_ICON_CODE" == "03n" ]; then WEATHER_SYMBOL="☁";
elif [ "$WEATHER_ICON_CODE" == "04d" ]; then WEATHER_SYMBOL="☁"; elif [ "$WEATHER_ICON_CODE" == "04n" ]; then WEATHER_SYMBOL="☁";
elif [ "$WEATHER_ICON_CODE" == "09d" ]; then WEATHER_SYMBOL="☔"; elif [ "$WEATHER_ICON_CODE" == "09n" ]; then WEATHER_SYMBOL="☔";
elif [ "$WEATHER_ICON_CODE" == "10d" ]; then WEATHER_SYMBOL="☂"; elif [ "$WEATHER_ICON_CODE" == "10n" ]; then WEATHER_SYMBOL="☂";
elif [ "$WEATHER_ICON_CODE" == "11d" ]; then WEATHER_SYMBOL="⚡"; elif [ "$WEATHER_ICON_CODE" == "11n" ]; then WEATHER_SYMBOL="⚡";
elif [ "$WEATHER_ICON_CODE" == "13d" ]; then WEATHER_SYMBOL="❄"; elif [ "$WEATHER_ICON_CODE" == "13n" ]; then WEATHER_SYMBOL="❄";
elif [ "$WEATHER_ICON_CODE" == "50d" ]; then WEATHER_SYMBOL="⛆";elif [ "$WEATHER_ICON_CODE" == "50n" ]; then WEATHER_SYMBOL="⛆";
if unknown icon, set text instead of symbol
else WEATHER_SYMBOL="$WEATHER_TEXT";
fi
output <symbol><space><temp-in-°C>
echo "$WEATHER_SYMBOL"" ""$WEATHER_TEMPERATURE""°C";
exit 0;
EDIT 2022-07-09: Since tuxnet24.de does not provide weather anymore. I changed the provider to openweathermap. (this also involves json beeing parsed instead of xml in the former version) /EDIT

- 268
-
-
Switching shebang to
#!/usr/bin/env bash
fixed for me, Ubuntu 18.04 – Philip Kirkbride Feb 16 '19 at 04:11 -
1
-
2rewrote script to use non-404-service. thanks for pointing out, @SurpriseDog – kai-dj Jul 08 '22 at 23:36
I've just made a quick endpoint that returns the weather, along with some more metrics:
curl https://curl-weather.herokuapp.com/
Note that it currently only displays the weather for London (UK). Here's the Github repo in case you'd like to clone or open issues: https://github.com/nkhil/weather-script

- 111
Although accuweather curl solution is pretty good I needed something more informational, so I created simple bash script that pulls info for next 4 hrs from weather.com website. As in previous example you have to modify link for your location.
Example output:
$ ./getWeather.sh
Temperature for 1 AM : 65°F and outside should be: Partly - Cloudy FEELS LIKE: 65°
Temperature for 2 AM : 65deg;F and outside should be: Partly - Cloudy FEELS LIKE: 65deg;
Temperature for 3 AM : 63deg; and outside should be: Partly - Cloudy FEELS LIKE: 63deg;
Temperature for 4 AM : 62deg; and should be: Mostly - Clear FEELS LIKE: 62deg;
Full script is located at: https://sites.google.com/site/wozoopalinux/home/wzbash001/get-weather-information-from-command-line-for-next-4-hrs

- 1
devs
between us – Timo Dec 10 '17 at 19:492021-05-31
. – stephanmg May 31 '21 at 07:39Follow @igor_chubin for wttr.in updates
– Mark Deven Jan 28 '22 at 21:17