hr_9pw
Last Updated: February 25, 2016
·
5.157K
· geetotes
537449ba51eeff09dc6a5fc50a0b5d4f

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

Say Thanks
Respond

4 Responses
Add your response

5191

You forgot to add to run update-motd.

over 1 year ago ·
6034
537449ba51eeff09dc6a5fc50a0b5d4f

I think cron will do that?

over 1 year ago ·
13279
Half life 2 logo

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 ·
13722
537449ba51eeff09dc6a5fc50a0b5d4f

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 ·