The welcome message shown to a user upon the terminal login whether it is via remote SSH login or directly via TTY or terminal is a part of motd also known as "Message Of The Day" daemon. The motd message can by customized to fit individual needs of each user or administrator by modifying the /etc/motd file or script within the /etc/update-motd.d directory.

In this tutorial you will learn:
  • How to append additional information to motd message
  • How to modify motd message
  • How to disable selected parts of motd daemon
  • How to completely disable motd message
Ubuntu 18.04 MOTD message after user login
Default Ubuntu 18.04 motd message.


Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Criteria Requirements
Operating System Ubuntu 18.04 Bionic Beaver
Software N/A
Other privileged access to your Linux system as root or via the sudo command
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

How to append additional information to motd message

It is possible to append additional information to the default motd message by creating a custom /etc/motd file. For example, let's append the default message with the Welcome Ubuntu User message.

Open up terminal or TTY console and enter the following linux command:
$ sudo sh -c 'echo "Welcome Ubuntu User" > /etc/motd'
custom motd text appended to a default Ubuntu's message
Re-login and confirm the custom motd text appended to a default Ubuntu's message.


How to modify motd message

Modifying the /etc/motd file is fast and effective way on how to quickly change the welcome message. However, for more elaborate configuration it is recommend to customize the MOTD via scripts located within the /etc/update-motd.d directory.

Message of the day is modular hence split into various scripts executed in order from lowest to highest number value as part of the script's file name prefix. The following scripts are located within the /etc/update-motd.d directory as part of the default motd daemon configuration:
$ ls /etc/update-motd.d/
00-header     50-landscape-sysinfo  80-esm        90-updates-available  95-hwe-eol      98-fsck-at-reboot
10-help-text  50-motd-news          80-livepatch  91-release-upgrade    97-overlayroot  98-reboot-required
Each script is assigned with executable permissions. Feel free to modify any of the above scripts to better fit the motd message output into your system environment.

As an exercise, let's customize the motd message to show general system information, hard disk usage and the weather information. Let's start by disabling the default scripts.

Depending on your needs you can selectively disable one or more scripts by removing the executable permissions. For our example we will disable all scripts and create a new 01-custom script.
  1. Disable all current default MOTD's daemon scripts
  2. $ sudo chmod -x /etc/update-motd.d/*
    
  3. Install prerequisites
  4. $ sudo apt install inxi screenfetch ansiweather
    
  5. Create a new script, eg. /etc/update-motd.d/01-custom with the following bash script:
    #!/bin/sh
    echo "GENERAL SYSTEM INFORMATION"
    /usr/bin/screenfetch
    echo
    echo "SYSTEM DISK USAGE"
    export TERM=xterm; inxi -D
    echo
    echo "CURRENT WEATHER AT THE LOCATION"
    # Show weather information. Change the city name to fit your location
    ansiweather -l bratislava
    
  6. Make this script executable
  7. $ sudo chmod +x /etc/update-motd.d/01-custom
    
All done. At this stage simply re-login on your Ubuntu 18.04 Server or desktop and confirm the new MOTD information.


Custom Message Of The Day information on Ubuntu 18.04 Server
Custom Message Of The Day information on Ubuntu 18.04 Server

How to disable motd message

As already shown previously the system administrator can disable one or more parts of the MOTD message output by removing the executable permissions of each relevant MOTD script. To disable all scripts entirely execute:
$ sudo chmod -x /etc/update-motd.d/*
Another option is to disable the MOTD message from appearing as on per user basis by creating a hidden .hushlogin within a user directory. Example:
$ touch $HOME/.hushlogin
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME or create a JOB ALERT on LinuxCareers.com job portal.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:



Comments and Discussions