Last Updated: February 25, 2016
·
9.524K
· geetotes

MOTDs on Amazon AMIs

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

4 Responses
Add your response

You forgot to add to run update-motd.

over 1 year ago ·

I think cron will do that?

over 1 year ago ·

Yeah, I've tried this several times now and haven't had any luck. I've tried symlinking a banner file to /etc/update-motd.d/30-banner and it didn't work. I've tried writing that file directly and it didn't work. The files themselves are all there, and have the correct content, but the MOTD never, ever pulls in my additional files.

Any ideas?

over 1 year ago ·

What does 'crontab -l' say (when you're the root user). It should mention update-motd. If not, use 'crontab -e' to add update-motd (make sure to use the full path) to root's crontab.

over 1 year ago ·