Custom MOTD in Linux Debian

by Adam Świątkowski
5 mins read
SSH Desk

MOTD stands for message of the day, in the Linux based systems it is the first screen which we see after logging into for example SSH. The main purpose of this module is to “message” users about for example planned outages, system upgrades or any other inaccessibility of server.

Default MOTD Debian
Default MOTD in Linux Debian

The above screenshot shows how the default message of the day in Linux Debian looks like. As we can see whe can find out current server time, last login IP and server’s IP (default information in message of the day can vary on other distributions). Surely you will agree with me that this is quite important information, however, as a system administrator, it would also be useful to know about things such as RAM, hard disk and CPU usage as soon as you log into the terminal. In this post I will show you my basic MOTD configuration so as to extend the above mentioned properties with additional interesting server data.

Install necessary software

In order to show more information in MOTD we need two addition packages – inxi and screenfetch. Screenfetch is an inconspicuous Bash script that will show us most of the information about our system, distribution and hardware resources. Additionally, this script will show the ascii logo of the detected distribution. inxi is a script that allows you to display information about your system hardware. It is written in Bash, so you can use it directly from the terminal, which is just right for display in MOTD. Let’s install all staff.

sudo apt-get update
sudo apt-get install screenfetch inxi

Create MOTD script

We have all of the necessary staff, so the next thing is to create our custom MOTD. Lets’do it!

Login as root user and create file named: 01-custom

sudo su -
nano /etc/update-motd.d/01-custom

This file will contain our script loaded as MOTD, you put there whatever scripts you want. Below I’ll show you my config.

#!/bin/sh
echo "GENERAL SYSTEM INFORMATION"
/usr/bin/screenfetch
echo
echo "SYSTEM DISK USAGE"
export TERM=xterm; inxi -D
echo

Save this file with CTRL + X and Y and that’s pretty much it. The only thing left for us to do is to disable the default MOTD and give executable (+x) rights for our script. Below are commands which needs to be executed for that. You need also to run them as root.

chmod -x /etc/update-motd.d/*
rm -f /etc/motd
uname -snrvm > /var/run/motd.dynamic
systemctl disable motd
chmod +x /etc/update-motd.d/01-custom
rm -rf /etc/update-motd.d/10-uname

After that reconnect to your terminal or SSH connection and if everything went well you will see the following MOTD.

MOTD template Linux Debian
MOTD template Linux Debian

Related Articles

This website uses cookies to improve your experience. I'll assume you're ok with this, but you can opt-out if you wish. Read Privacy Policy. Accept