Skip to main content

Weather Reports when Logging into Ubuntu Server

By January 6, 2014September 12th, 2022No Comments

When you log in to the command line environment of your Ubuntu 12.04 server you are presented with the file /etc/motd; the message of the day. The file is extensible through the /etc/update-motd.d/ directory structure and in this tutorial we are going to investigate how we display the local weather inside the MOTD file. You will need to know your local weather station and the code can be gained from .

Ubuntu MOTD

The MOTD or /etc/motd file is common in Linux. This is a called in Ubuntu Linux form the /etc/pam.d/login file as references by the PAM (Pluggable Authentication Module)

When we use the login program the module is called the /etc/motd/ displayed. Rather than just a static file the contents of /etc/update-motd.d/ are also run. These are scripts or sym-links to scripts that will display additional information in the MOTD file. The following is the default MOTD file run with the command

cat /etc/motd


The package weather-util is in the standard Ubuntu repositories and can be used to show weather reports from around the world

apt-cache show weather-util

We can install this using:

apt-get update
apt-get install weather-util

With it installed we can retrieve reports once we know the weather station code. Here we look at Wittering in the UK.

weather -i EGXT

Locate your closest weather station

By visiting the URL : you may locate weather station in your state or country.

Create the script

To ensure this is displayed upon login we need to add a script or sym-link into the directory /etc/update-motd.d/. These scripts start with a number and the higher the number the later the script is run. We will use 98 to match the other scripts run vi from a root prompt:

vi /etc/update-motd/98-local-weather
 weather -i EGXT
chmod 755 !$

Then simply log out and back in again from the terminal or SSH