Translation(s): English - Italiano

/etc/motd in Debian

Debian has a peculiar way of handling /etc/motd. The motd is updated at every reboot, in a boot script (/etc/init.d/ in lenny and below, /etc/init.d/bootlogs in squeeze and above), which basically runs the following:

uname -snrvm > /var/run/motd
[ -f /etc/motd.tail ] && cat /etc/motd.tail >> /var/run/motd

Since /etc/motd is a symlink to /var/run/motd in Debian, this works.

How to update your /etc/motd

Since /etc/motd basically gets overwritten at every reboot, you need to instead update /etc/motd.tail and either reboot (!!) or also edit /etc/motd.tail or run the above commands. There is a bug report (437176) to provide an easier command to allow you to update only /etc/motd.tail.

How to script updates to your /etc/motd

A little less known thing about /etc/motd in Debian and Ubuntu is that pam will actually update your /etc/motd based simply on the scripts in /etc/update-motd.d. So to replicate the above scripts, you could do:

mkdir /etc/update-motd.d
cat > /etc/update-motd.d/10uname <<EOF
#! /bin/sh
uname -snrvm
cat > /etc/update-motd.d/20tail <<EOF
#! /bin/sh
[ ! -f /etc/motd.tail ] && exit 0
cat /etc/motd.tail
chmod a+x /etc/update-motd.d/*

Then you could add other scripts to your /etc/update-motd.d directory to add stuff to your /etc/motd. See the manpage for more information.

Note that this technique is using a patch that is shipped only with Debian and Ubuntu and not factored into upstream PAM. Furthermore, this code has had security issues in the past (CVE-2010-0832, this bug).

How to keep your /etc/motd from being overwritten

rm /etc/motd
cat > /etc/motd <<EOF
This is my message of the day!

This way, /etc/motd is not a symlink to the updated one anymore and will therefore always stay the same. The downside to this is that you will not see the latest kernel version in the motd.

Old school "don't touch my motd" approach

Similar to the above, this approach also makes sure dynamic information can be displayed...

cat > /etc/profile.d/uname <<EOF
uname -snrvm
rm /etc/motd
cat > /etc/motd <<EOF
Known issues

 * the kerkuffle is known to not restart properly on reboot, to restart use the command
   service kerkuffle restart

Who's responsible for /etc/motd?

Here's a list of packages which do that work:

base-files: /usr/share/base-files/motd
base-files: /usr/share/base-files/motd.md5sums
manpages: /usr/share/man/man5/motd.5.gz
manpages: /usr/share/man/man5/motd.tail.5.gz
libpam-modules: /lib/x86_64-linux-gnu/security/
initscripts: /etc/init.d/bootlogs


Currently /etc/motd is user editable and static in Wheezy - The file will not be overwritten by reboot.

What others do


Since Ubuntu Intrepid Ibex (2008.10), Ubuntu has had a /etc/update-motd.d/ directory, from which scripts are ran to update the /etc/motd file. This is now factored into the pam_motd module, which updates the /var/run/motd file, using this C code:

    if (do_update && (stat("/etc/update-motd.d", &st) == 0)
        && S_ISDIR(st.st_mode))
       mode_t old_mask = umask(0022);
       if (!system("/usr/bin/env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin ru
n-parts --lsbsysinit /etc/update-motd.d > /var/run/"))
           rename("/var/run/", "/var/run/motd");

For a short while, this was instead done by the update-motd pacakge every 10 minutes.

By default Ubuntu ships with a set of scripts that add the number of packages to be update (for example).


Gentoo doesn't display the motd file by default, but this can be enabled in login.defs, see this wiki page.

Arch, CentOS, and others

According to this this wiki page, Arch doesn't seem to do anything special to /etc/motd other than display it on boot.


In FreeBSD, the motd file is also generated through a boot script, which will preserve modifications by changing only the line that matches (loosely) the uname that gets updated on reboots. The magic lines:

T=`mktemp -t motd`
uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T}