3

I've just made the transition to Ubuntu Linux 12.10 and I want to properly set up my first motd. I've run the following below and noticed that I only have one motd file instead of having a secondary file called motd.tail that most Ubuntu versions seem to have. Should I create backup copy the motd file and then write to that file, or write to the file directly? Also, once I've written to this file do I need to make it executable to display the message?

ls -l motd* // output: motd -> /var/run/motd
1
  • The way to update the MOTD has changed as of 14.04. If you got here from a generic search (as I did) and are using the newer OS, try this answer: askubuntu.com/a/623785/338568 May 14, 2015 at 20:32

3 Answers 3

6

As you've seen, /etc/motd is a symlink to /var/run/motd.

/var/run/motd is updated by a series of scripts that you'll find in the /etc/update-motd.d directory. The last of those scripts, 99-footer prints the contents of /etc/motd.tail, if it exists, and the output of 99-footer is appended to /var/run/motd.

A comment in /etc/update-motd.d/99-footer says:

# motd.tail is reserved for the admin to append static
# trailing information to a dynamically generated
# /etc/motd.
#
# To add dynamic information, add a numbered
# script to /etc/update-motd.d/

So /etc/motd.tail is the usual way to append static content to /etc/motd.

Of course, if you prefer, you can change all that, for example by making /etc/motd a standalone file with whatever contents you like. But then you'd lose the useful information added by the existing scripts.

And no, you don't need to make either motd or motd.tail executable, since they're not meant to be executed.

1

Oviously not 100% ubuntu, but I guess the handling is not that much different.

/etc/motd is just a symbolic link to var/run/motd which in turn on system startup gets filled with the contents of /etc/mod.tail.

So it's just the file /etc/motd.tail you'd have to fill with your message, while leaving everything else intact if you don't want to break this scheme.

Here's the output of man motd on debian. I guess it's the same for ubuntu, but better check yourself.

DESCRIPTION

   The  contents  of  /etc/motd  are displayed by login(1) after a successful
   login but just before it executes the login shell.

   The abbreviation "motd" stands for "message of the day", and this file has
   been traditionally used for exactly that (it requires much less disk space
   than mail to all users).

   On Debian GNU/Linux this file is a symbolic  link  pointing  to  /var/run.
   The  contents of this file are regenerated upon every system boot based on
   the contents of /etc/motd.tail.

FILES /etc/motd /etc/motd.tail

... and don't forget to make sure the pam_motd module get's run during login. Otherwise you won't see a thing of your message.

1
  • Appreciate the feedback, I got it!
    – Dford.py
    Mar 6, 2013 at 0:15
1

I wanted to add this to the conversation, as things have changed quite a bit since the last answers.

In short MOTD is now run by pam_motd, and /etc/motd is no longer a symlink... it does not even exist.

  • /etc/motd – The classic, static file. Does not exist anymore in Ubuntu 16.04 LTS, not even as a symbolic link to /var/run/motd. If it is created, however its contents will be printed too.
  • /var/run/motd – This was used by Ubuntu’s first implementation. It is not used anymore. It is just ignored by PAM.
  • /var/run/motd.dynamic – This is what is shown on login currently. It is updated by /etc/init.d/motd at every boot. It is also updated by PAM by running the scripts in /etc/update-motd.d/, if they exist.
  • /etc/motd.tail – The Ubuntu package used to populate /etc/update-motd.d. One of them would cat the contents of this file so it was easy to add static content. That script does not exist in the package anymore, so the file does not have the intended effect.

Updated info here

https://ownyourbits.com/2017/04/05/customize-your-motd-login-message-in-debian-and-ubuntu/

You must log in to answer this question.