Ever modified /etc/motd on an EC2 instance only to find that you've erased the handy counter of system updates? Or worse, the motd will revert back to the original upon reboot?
Here's how to do it the right way.
The motd on AMIs is generated by running /usr/sbin/update-motd on a crontab. This script mushes together everything that's in /etc/update-motd.d/.
To add a new message to your motd without borking everything else, simply add a new file (or script) to /etc/update-motd.d/. For example, my directory looks like this
-rwxr-xr-x 1 root root 220 Mar 27 15:45 30-banner
-rwxr-xr-x 1 root root 140 Dec 17 2011 40-figlet
-rwxr-xr-x 1 root root 134 Mar 27 15:45 70-available-updates
-rwxr-xr-x 1 root root 2103 Mar 27 15:45 75-system-update
As you can see, I've added a 40-figlet script that will generate a l337 message that will appear right under the banner.
Don't forget that /etc/motd is actually a symlink to /var/lib/update-motd/motd
Stay tuned for my new book: What's my MOTD? Message of the Day Best Practices and Anti-Patterns