Gentoo Wiki


MOTD - Message of a day - is a message (usually a quotation or a saying) that is displayed to you just after you successfully login to the system.


echo " Gentoo is great and so am I" > /etc/motd


Open a new console <ctrl>+<alt>+F1 and try to login, your MOTD should show up :)

Rotating MOTDs

Displaying the same message all the time would be quite boring, that's why one wants to rotate MOTDs automatically.

Here is a simple script that take list of one-per-line (enter separated :) ) MOTDs located in /etc/motds and rotates them "randomly" every day. In an editor, write this script:

# this script takes a random line from /etc/motds and inserts it to /etc/motd
# WATCHOUT: This script will override everything in your motd-file (/etc/motd) 
# bugs/ideas, please contact me at

skip_lines=10   # heading in motds file; number of lines to be skipped
rand=         # a random number
motds="/etc/motds"      # path to motds list file
motd="/etc/motd"        # motd system file
msg=                  # text printed in MOTD

if [ ! -f $motds ]; then echo "Error: Motds list file not found : $motds" 1>&2;
else    # we're Ok, let's get working 
        # get a pseudo-random number
        skip_lines=$(($skip_lines + 1 )) # increase $skip_lines +1
        max_lines=`cat $motds | tail -n+${skip_lines} | wc -l 2>/dev/null` # how many motds do we have  
        # echo " we have $max_lines motds to choose from"

        rand=$((rand + 1 ))              # now, $rand is in range 1..$max_lines - so we can match a line in $motds

       m=`cat $motds | tail -n+${skip_lines} | sed -e " ${rand}! d " 2>/dev/null `  # get the motd

        msg="\n MOTDs brought to you by $HOSTNAME ($OSTYPE) \n \n \t $m \n"
        echo -e $msg > $motd  # print line number $rand to $motd

Save this file somewhere safe,eg. /usr/local/bin

Make it writeable just by root:

# chmod go-w && chmod ugo+x

and if you want your MOTD to change daily, this can be achieved by using cron:

ln -s /usr/local/bin/ /etc/cron.daily/

Now just pollute your /etc/motds file and you are ready to GO! :) PS: You can use \n \t and that sort of backslash-characters to format your motd ; eg line up \n \t line down

Retrieved from ""

Last modified: Fri, 05 Sep 2008 23:27:00 +0000 Hits: 2,693