The message of the day file (
/etc/motd) used to be so simple… but with great power often comes increased complexity. The Ubuntu
motd file is very powerful and can be manipulated easily once you know how.
The actual file is composed in
/var/run/motd so that the
/etc file system can still be considered read only and the file
/etc/motd is a symbolic link to
/var/run/motd. To make the
motd file a static file as before, just change the link to another file such as
In older versions of Ubuntu, the file
/etc/motd.tail was introduced for this purpose; however, it has been deprecated for some time in favor of the newer
/etc/update-motd.d framework. The
/etc/motd.tail file can still be used and is adapted into the new framework.
update-motd framework was introduced with the
update-motd package in Ubuntu Intrepid; it now resides in the
libpam-modules package as part of the
In earlier versions of
/etc/update-motd.d directory contained multiple directories that would be executed hourly, daily, weekly, or monthly. The scripts would be executed by a daemon
update-motd that was run from cron.
In Ubuntu Lucid, this structure was phased out in favor of a straight sequential operation. The
motd file is now generated by the
pam_motd module upon login.
Each of the files in the
/etc/update-motd.d is executed in numerical order; those in a Ubuntu Lucid Server install are:
/etc/update-motd.d# ls -l total 28 -rwxr-xr-x 1 root root 57 2010-04-23 04:45 00-header -rwxr-xr-x 1 root root 248 2010-04-23 04:45 10-help-text -rwxr-xr-x 1 root root 65 2010-04-13 15:45 20-cpu-checker lrwxrwxrwx 1 root root 46 2010-12-02 12:26 50-landscape-sysinfo -> /usr/share/landscape/landscape-sysinfo.wrapper -rwxr-xr-x 1 root root 71 2010-04-13 15:45 90-updates-available -rwxr-xr-x 1 root root 61 2010-06-30 09:01 91-release-upgrade -rwxr-xr-x 1 root root 69 2010-04-13 15:45 98-reboot-required -rwxr-xr-x 1 root root 261 2010-04-23 04:45 99-footer
These files generate a
motd like this:
Linux myserver 2.6.32-32-server #62-Ubuntu SMP Wed Apr 20 22:07:43 UTC 2011 x86_64 GNU/Linux Ubuntu 10.04.2 LTS Welcome to the Ubuntu Server! * Documentation: http://www.ubuntu.com/server/doc System information as of Tue Nov 22 11:01:48 CST 2011 System load: 1.84 Processes: 167 Usage of /: 80.6% of 115.84GB Users logged in: 0 Memory usage: 50% IP address for lo: 127.0.0.1 Swap usage: 10% IP address for eth0: 10.6.7.1 Graph this data and manage this system at https://landscape.canonical.com/ 21 packages can be updated. 0 updates are security updates. *** System restart required *** Last login: Fri Nov 18 09:46:33 2011 from 192.168.15.1
SSH introduces some slight complexity: SSH has its own handling of the
motd file and can produce it upon demand. In a Ubuntu Lucid install, this capability is turned off because the PAM framework shows the
motd through the
pam_motd module on login.
Despite the documentation for
motd.tail stating otherwise, there is no
/etc/init.d/bootmisc.sh that runs and creates
/var/run/motd; this is done upon login as previously mentioned.
If logging in with SSH, the SSH display of
motd may be turned off either by adding a file
~/.hushlogin or by reconfiguring the server with a
PrintMotd No option. Note that this is separate from the
pam_motd process; thus if a Ubuntu system has
PrintMotd Yes as well as
pam_motd you will see double messages. Likewise, if a
~/.hushlogin file is present – or the option
PrintMotd No is set – the
pam_motd module will still run and a message of the day will still be seen.
In the PAM configuration of a standard Ubuntu Lucid install, both
/etc/pam.d/ssh contain the
pammotd module. The
/etc/motd file is selectable here; a different file entirely could be used by modifying the
motd line appropriately:
session optional pam_motd.so motd=/etc/motd.other
To modify the
motd within the
update-motd framework, just create (or delete) scripts in the
/etc/update-motd.d directory. Each script must be in the format NN-xxxxxxx where the first two numbers NN specify the order and the last xxxxxxx specifies a reasonable name for the script. The script should be an actual file and not a link, according to the documentation (although the
50-landscape-sysinfo script is a symbolic link!).
Output should be to stdout and start with a blank line and end with a newline. Remember that the script will execute on every login, so it should be quick.