6

My /etc/motd file is showing duplicate messages. When I edit it manual, it keeps returning to the messed up version whenever a user logs in. How do I stop this? I'm using Ubuntu 10.04

MrD
  • 259
  • 1
  • 4
  • 10

3 Answers3

7

By default, in recent releases of Debian and Ubuntu (including yours), /etc/motd is a symbolic link to /var/run/motd, which is regenerated at each login by the update-motd framework.

If you want a static /etc/motd remove a symbolic link and create a regular file in its place. Or you can edit the pam_motd calls in /etc/pam.d/* and pass motd=/etc/motd.dougk.

The underlying issue is probably due to some breakage in /etc/update-motd.d/*, possibly a backup file duplicating the effect of the corresponding main file.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
  • How this helped me fix it: I commented out one of the `pam_motd` lines in `/etc/pam.d/` and now I'm back to a single MOTD. Thanks! – adam_0 Jan 30 '13 at 18:52
5

The MOTD is generated by a script. To prevent the default MOTD from reverting, remove the execute bit from the /etc/update-motd.d/00-header file and put your desired MOTD text into /etc/motd.tail. Or, to keep the default MOTD text and just append your own text to it, leave the 00-header file alone and add your text to the motd.tail file.

Andrew Lambert
  • 2,358
  • 1
  • 16
  • 17
0

To contribute with a more updated answer:

/etc/motd is no longer a symlink as of Ubuntu 16.02. In debian it is just a regular file.

pam_motd calls all scripts in /etc/update-motd.d with run-parts to populate /var/motd.dynamic

Both /var/motd.dynamic and /etc/motd are concatenated for MOTD

Details here

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

nachoparker
  • 879
  • 11
  • 7