Although most Linux users will use a GUI tool to retrieve weather information, it is also possible to do get a weather forecast from the command line. Whether you are stubborn command line user or you wish to automate flower watering using your Linux system and cron, there are several different options that can do the job. Some tools even allow you to retrieve information such as current outside temperature, wind, pressure, humidity, altitude, and more, directly from your Linux terminal.
In this tutorial, you will see how to install and use several different software packages to retrieve the weather information on Debian based and Red Hat Linux based systems.
In this tutorial you will learn:
- How to retrieve weather forecast via inxi, weather-util, ansiweather, and wttr.in
- How to install weather utilities on Linux
|Requirements, Conventions or Software Version Used
|Any Debian based or Red Hat Linux based systems
|inxi, weather-util, ansiweather, curl
|Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Retrieve Weather information using Linux command line
There are several ways to retrieve weather information on the Linux command line. See the various methods below and then choose whichever one you find most suitable for your environment and preferences.
Option 1: inxi
Installation of inxi:
Debian based systems: $ sudo apt install inxi RHEL based systems: $ sudo dnf install inxi
Retrieve your weather from
inxi with the
$ inxi -w Weather: Report: temperature: 12.2 C (54 F) conditions: Overcast clouds Locale: current time: Sun 08 May 2022 11:04:04 PM EDT (America/New_York) Source: WeatherBit.io
inxi works off of your configured time zone. You can use the following command to verify your currently configured time zone:
$ ls -l /etc/localtime lrwxrwxrwx 1 root root 36 May 7 16:35 /etc/localtime -> /usr/share/zoneinfo/America/New_York
To get more information such as pressure or humidity from the inxi’s command output simply include
$ inxi -xxxw
-W command line options
inxi is also capable to retrieve weather information from any other remote location around the world. The arguments to
-W option should be in city,state OR latitude,longitude OR postal/zip code format. For example let’s retrieve Warsaw,Poland weather information:
$ inxi -W Warsaw,Poland Weather: Conditions: 48 F (9 C) - shallow fog Time: June 25, 4:30 AM CEST
Do not fear if your location is not included as part tzdata data. inxi is able to retrieve information from the closest weather information point based on latitude and longitude:
$ inxi -xxxW 23.545988,8.853559 Weather: Conditions: 79 F (26 C) - Clear Wind: From the West at 9 MPH Humidity: 17% Pressure: 30.15 in (1021 mb) Location: Djanet (AL) Altitude: 967 ft Time: June 25, 3:38 AM CET Observation Time: June 24, 11:00 AM CET
Option 2: weather-util
Installation of weather-util:
Debian based systems: $ sudo apt install weather-util
weather-util, just specify the location for which you would like to receive a weather report.
$ weather-util sydney
If your search is too ambiguous, i.e. there are multiple cities with the same name, you can narrow it down by using the code at the beginning, as you will see the in the screenshot below.
Option 3: ansiweather
Installation of ansiweather:
Debian based systems: $ sudo apt install ansiweather
To use ansiweather, add the
-l option and then specify the location that you would like to check the weather for.
$ ansiweather -l charleston sc
You can add the
-F option to get a five day forecast.
$ ansiweather -F -l lima peru
Option 4: wttr.in
wttr.in is a weather report website that displays in simple ASCII. This makes it ideal for downloading the website from command line and viewing the forecast. Curl is the best tool to use with this website and can be installed with these commands:
Debian based systems: $ sudo apt install curl RHEL based systems: $ sudo dnf install curl
To get the weather forecast from the website, just use
curl like so:
$ curl wttr.in
You can get the weather forecast for a specific location by putting your search query in the URL itself. This link will get the weather forecast for Charleston, SC.
$ curl https://wttr.in/charleston-sc
In this tutorial, we saw how to retrieve weather information and a forecast via command line on a Linux system. If you do not wish to install and additional software, curling the
wttr.in website works very well and has a nice looking display of the forecast for any location. If you do not mind installation an extra software package, we have given you a few to choose from in this tutorial.