How is /etc/motd updated?
It's updated by pam_motd
on login. The update-motd manual page describes this:
Ubuntu introduced the update-motd framework, by which the motd(5) is
dynamically assembled from a collection of scripts at login.
Executable scripts in /etc/update-motd.d/* are executed by pam_motd(8)
as the root user at each login, and this information is concatenated in
/var/run/motd. The order of script execution is determined by the run-
parts(8) --lsbsysinit option (basically alphabetical order, with a few
caveats).
On Ubuntu systems, /etc/motd is typically a symbolic link to
/var/run/motd.
The accepted answer above is correct, however incomplete. I'm hoping this provides a bit more info for the OP.
Basically, on a fresh install, the motd is generated from three places:
- The scripts in
/etc/update-motd.d/
- The compiled binaries controlled by
/etc/pam.d/login
- The
/etc/legal
file
Number 3 there refers to the block of text at the end of your motd that includes "Ubuntu comes with ABSOLUTELY NO WARRANTY ...", that's the /etc/legal
file. However you will not find anything under /etc/update-motd.d/
that mentions it, nor does the word "legal" appear anywhere in the /etc/pam.d/login
file. It's inclusion has been made obscure and I really don't know how it gets in there. I mean I know there's a {$HOME}/.cache/motd.legal-displayed
but I don't know where that comes from either (yet).
The /etc/pam.d/login
file is responsible for the notification of pending email, however that is not obscure. There's a nice comment describing:
Prints the status of the user's mailbox upon successful login
...right there in the file. I suppose technically that is not really a part of the motd, but it shows up at login and if you're new that fine distinction may not be appreciated.
On a fresh install of 14.04 there is no /etc/motd
file. If you create one (or create a motd.static and symlink it to motd) the contents of that file will be appended to text generated by the update-motd.d
scripts but the contents of /etc/legal
will stop showing up. Go figure. The email notice still appears so this does not interrupt the /etc/pam.d/login
script so I doubt /etc/legal
is being pulled in from there. Its sourcing remains a mystery for the reader. I have noticed that when I remove the /etc/motd
link (or file) the legal disclaimer does not immediately come back. It takes a few minutes. I did not want to constantly see the disclaimer so I deleted the text from that file.
Cheers.
To expand a little on David Kuhl's answer:
A fresh install of Ubuntu Server 14.04.1 LTS apparently does not install landscape-common nor update-notifier-common packages. Thus the following scripts are not installed:
/etc/update-motd.d/50-landscape-sysinfo
/etc/update-motd.d/90-updates-available
Thus, to get all of the ssh login information available from servers migrated from 12.04 LTS one must install the above packages manually:
sudo apt-get install landscape-common update-notifier-common