MOTD (stands for “Message of the Day”) is a message that is displayed to users when they log in to a Linux system. The MOTD is displayed after a user successfully logs in to the server using ssh. The MOTD is typically stored in a file called “/etc/motd”, and it can be used to provide users with important information, such as announcements, security advisories, or system status updates.
This article aims to explain various methods to show the MOTD in Linux. The content of this tutorial is mentioned below:
- Prerequisite: Check the SSH Services
- Add MOTD in Linux
- Show the MOTD in Linux
- Verify MOTD During Login to Server
Let’s start with the prerequisite.
Prerequisite: Check the SSH Services
To check the services of ssh, the “systemctl” utility is used with the “status” option as below:
$ sudo systemctl status sshd
How to Add MOTD in Linux?
To customize the MOTD on the system, you can edit the “/etc/motd” file using a text editor such as vi or nano. Use the sudo command to gain the necessary privileges to edit this file.
$ sudo nano /etc/motd
It navigates to the particular file using the “sudo” privilege. After that, add the message according to choice. For instance, a message is written as below:
$ """"Itslinuxfoss World"""""
How to Show the MOTD in Linux?
To display the MOTD in Linux, you can use the “cat” command to view the contents of the “/etc/motd” file. The added MOTD will be displayed after executing the script:
$ cat /etc/motd
Alternatively, you can use the less command to view the contents of the “/etc/motd” file in a paginated format:
$ less /etc/motd
Make File Executable
Make sure to set the script to be executable with “chmod +x” command and then run it with “/etc/motd” to test it.
$ sudo chmod +x /etc/motd
After the successful execution of the command, login to the server.
Verify MOTD During Login to Server
To verify the MOTD in Linux; users can log in to the server by specifying the “IP address”. It requires password authentication to log in to the server:
The output shows that “”””” Itslinuxfoss World ”””””” has been shown in Linux.
That is how to show the MOTD in Linux.
Linux offers the “cat” command to display the “MOTD” in the terminal. After modification in the “/etc/motd” file, the user can display the custom MOTD during login to the server. MOTD is a useful tool for providing users with important information and updates about the system. This guide has explained all possible steps to show the MOTD on the login screen of Linux.