The message of the Day (MOTD) is a banner message displayed automatically to users when they log into a linux system via a terminal or SSH. its commonly used to display system information, security warnings, maintenance notifications, or any custom message an administrator wants to communicate to users.
The default MOTD message is stored in /etc/motd file, for dynamic MOTD updates are handled by scripts located in /etc/profile.d/
How to configure the MOTD
There are two different method/types for the message of the Day (MOTD)
Static Message
Dynamic Message
Displaying a static MOTD
To create a simple, static message
Step1:
Edit the /etc/motd file
$ vi /etc/motd
Step2:
Add content to the file and save it
Step3:
Verify the MOTD by logging out and logging in back.
Displaying a Dynamic MOTD
To create a dynamic MOTD message through scripts
Step1:
Create a custom script in /etc/profile.d/
$ vim /etc/profile.d/motd.sh
Step2:
Add/Write message script the file and save it.
Step3:
Make script executable:
$ chmod a+x /etc/profile.d/motd.sh
Step4:
Verify the MOTD by logging in the server from the new terminal/shell.
Enabling and Disabling MOTD in SSH configuration file.
If you want to disable the MOTD for SSH Logins
Step1:
Edit the SSH Configuration file /etc/ssh/sshd_config
Step2:
File and modify the following line as needed.
Step3:
Reload the SSH Service:
$ systemctl reload sshd
Real-World Example of Dynamic MOTD
An advanced dynamic MOTD script to display system health:
Summary
MOTD Location: /etc/motd for static messages and /etc/profile.d/ for dynamic scripts
Purpose: Display important system messages, warnings, or information of the system.
Dynamic Updates: Add scripts in /etc/profile.d/ for real-time updates.
SSH Config.: Control MOTD display with PrintMotd directive.
MOTD (Message Of The Day) is a simple yet powerful tool for Linux Administrators to communicate with users effectively.
No comments:
Post a Comment