Linux Message of the Day

From packets2photons
Jump to navigation Jump to search

I like to make my message of the day as useful as possible. When I login via ssh I want it to be really clear as to which machine I am using and the specifications of that machine. The way that you do this varies between different distributions. Below are some examples of Ubuntu and Arch.

Ubuntu

There are a couple of packages that I like. You can install them with:

sudo apt install figlet neofetch

You can edit the message of the day with:

vim /etc/update-motd.d/00-header

At the bottom of this file I usually insert the following lines:

figlet -f small Welcome to [Insert_server_name_here]
neofetch

I usually then explore the other parts that are added by subsequent files in /etc/update-motd.d/ if I don' find the other information useful then I just delete.

As an example, on my amazon EC2 machine I did:

sudo rm /etc/update-motd.d/10-help-text 
sudo rm /etc/update-motd.d/50-landscape-sysinfo
sudo rm /etc/update-motd.d/50-motd-news  
sudo rm /etc/update-motd.d/51-cloudguest 
sudo rm /etc/update-motd.d/80-esm 
sudo rm /etc/update-motd.d/80-livepatch

Arch

Arch Linux does not feature a dynamic message of the day. It will simply read and print whatever the contents of /etc/motd. This means that you will need to use cron to periodically insert the data into the motd. Start by installing the correct packages.

pacman -S figlet neofetch cronie

Then you want to create a script

vim /bin/motd-script
#!/bin/bash

figlet -f small Welcome to Archbox
neofetch

Provide execute permissions

chmod 755 /bin/motd-script

You will then want to get this updated.

vim /etc/cron.hourly/0anacron

If permissions need changing then change the permissions on this file also

chmod 755 /etc/cron.hourly/0anacron

and find a place to insert the following:

/bin/motd-script > /etc/motd

Raspbian

The Raspberry Pi instructions are the same as Arch. The only way they differ is the installation of the packages being apt based. Cron configuration also differed as below:

 sudo vim /etc/crontab

I then inserted the following line to use the script to update the motd

24 *    * * *   root    /bin/motd-script > /etc/motd

Other

Sometimes I like running:

/usr/games/cowsay -f /usr/share/cowsay/cows/default.cow Hello, $(w -h | awk '{print $1"@"$3}') I am $HOSTNAME