Working on commandline for about four years now I feel like I want to do everything from there even browsing on the internet. Maybe you never thought to get weather forecasts from Linux commandline, but you never know until you read an article from me. So now open a new terminal emulator on your machine and be ready to try some cool tools that will help to get weather conditions on Linux anytime you need it.
A nice utility I use to get weather on my machine is the weather which can be installed on Ubuntu using the command shown below.
sudo apt-get install weather-util
Once the installation of the package weather-util is finished type the following command on your terminal emulator.
An error will be echoed on your console. It will tell you to put an id which is required for giving back the conditions.
weather: error: id required for conditions
The option -i can be used to specify an id. According to the official documentation about the weather tool you need the METAR station ID of the place you want to receive weather conditions.
The following example is very practical and easy to understand how to make use of the option -i while using the weather utility.
weather -i KRDU
The above command turns the result shown below.
Current conditions at Raleigh-Durham International Airport, NC (KRDU) Last updated Apr 14, 2015 - 01:51 AM EDT / 2015.04.14 0551 UTC Temperature: 66.0 F (18.9 C) Relative Humidity: 72% Wind: from the S (170 degrees) at 3 MPH (3 KT) Sky conditions: mostly cloudy Precipitation last hour: A trace
You can google for the METAR station id. For example If I want to find the weather conditions of the city I actually live which is Tirana I just use the following command.
weather -i LATI
Then I get the following output.
Current conditions at Tirana, Albania (LATI) 41-20N 019-47E 90M (LATI) Last updated Apr 14, 2015 - 02:20 AM EDT / 2015.04.14 0620 UTC Temperature: 55 F (13 C) Relative Humidity: 76% Wind: from the S (180 degrees) at 5 MPH (4 KT)
A useful website I recommend to find the METAR id for the place you want to gather weather information is this one. Anyway you can just google and the right results will come up.
I am also curious to know weather conditions at Krakow, Poland. I use the following command.
weather -i EPKK
And get the following output after running the above command.
Temperature: 41 F (5 C) Relative Humidity: 60% Wind: from the W (280 degrees) at 14 MPH (12 KT) Sky conditions: partly cloudy
As you guys can see from the above examples the weather utility gives us information on the temperature both in Fahrenheit and Celsius, relative humidity, wind and also sky conditions.
This tool is really great as it does its job very fast. What really makes it useful is the detailed and human readable information it provides about weather conditions of a country or a city.
There are many other options available to the weather utility such as -c or –city=CITY for specifying a city, -z for alert zones, -m for metric units, -h to show some help message but we are not going to teach them here as it is best for you to try them yourself by experimenting in the commandline.
Another tool I often use when I want to get weather conditions on a city is the weatherman. I can not find it on the default repos of my Ubuntu machine so I decided to teach you how to install this cool tool from source.
Open a new terminal and download the weatherman using the following command.
curl -o weatherman-1.2.2.tar.gz -L https://github.com/subrosa/weatherman/archive/1.2.2.tar.gz
Then check if the download is done and the file is where you placed it.
ls | grep weatherman
The above command should produce the following output.
Now use the tar utility to extract the archive like shown below.
tar -zxvf weatherman-1.2.2.tar.gz
Change directory using the cd command.
Then copy the weatherman executable binary inside /usr/bin directory like shown below.
sudo cp weatherman /usr/bin
Finaly run the following command.
sudo chmod a+x /usr/bin/weatherman
And now you can use weatherman on your machine. Want to test it? Just run the following command on your console.
You will be presented to alot of output. This output contains information on usage of the tool, examples and options that can be used to help you during the weather conditions gathering on. I find it very easy to make use of weatherman. Basically all you need to know in order to get weather conditions on a place while using this tool is just the name of the place.
weatherman "Tirana, Albania"
The above command runs without any errors. It gives me the following information.
Current Conditions for Tirana, Albania Reported by Tirana @ Apr 14, 2015 8:50 AM Temp: 14 C : : High: 14 C Wind Speed: NNE 3 Rain: 0.00mm Low: 8 C Gust: SSE 8 Rain/Month: 0.00mm Feels Like: 14 C Avg Wind: NNE 0 Sunrise: Humidity: 67% Pressure: 1024.05mb Sunset: Dew Point: 8 C Moonphase: Waning Crescent
If you would like to use metric units just use the option -m like shown in the following command.
weatherman -m "Tirana, Albania"
In case you want to use English units such as Fahrenheit and inches use the option -e like shown below.
weatherman -e "Tirana, Albania"
The following is the result of the above command. As you guys can see units have changed from the default ones.
Current Conditions for Tirana, Albania Reported by Tirana @ Apr 14, 2015 8:50 AM Temp: 57 F : : High: 57 F Wind Speed: NNE 2 Rain: 0.00" Low: 46 F Gust: SSE 5 Rain/Month: 0.00" Feels Like: 57 F Avg Wind: NNE 0 Sunrise: Humidity: 67% Pressure: 30.24" Sunset: Dew Point: 46 F Moonphase: Waning Crescent
To get the version of the weatherman utility you are currently using just type the command shown below.
Mine is version 1.2.2. You can tell it by the output the above command produces.
I am very curious to know the weather conditions in Warsaw, Poland so let me perform a last check with the weatherman utility.
weatherman "Warsaw, Poland"
And the following results are displayed on the console.
Current Conditions for Warsaw, Poland Reported by Warsaw (Okecie) @ Apr 14, 2015 9:00 AM Temp: 6 C : : High: 6 C Wind Speed: WNW 19 Rain: 0.00mm Low: 1 C Gust: WNW 19 Rain/Month: 0.00mm Feels Like: 2 C Avg Wind: NNE 0 Sunrise: Humidity: 66% Pressure: 1022.02mb Sunset: Dew Point: 0 C Moonphase: Waning Crescent
The weatherman utility does not have as many options as weather tool but it definitely does a great job and is easier to use. All you need is the name of the city and boom. It does everything for you. Why complicate life with ids and stuff?
So, if you want something practical, easy to use and ready to go just make use of weatherman. You have everything you need to make a check of basic weather conditions.
On the other hand weather-util has more options but it is a bit hard for a beginner to figure out how it works. But since we are nerds and love experimenting I highly recommend to try it alot.
I am very sure there are many different ways to get weather forecasts on the Linux command-line. Maybe other tools we don’t know and even shell scripts written in bash scripting by some nerds on their basement. In this article we took a very practical approach and tested two popular tools among Linux users for gathering weather information.
In short words weatherman and weather work great, but if you know another tool or some hack that can be used to get weather information from the Linux console please do not hesitate to share it with us. We will be very happy if you do that!