How to Create a Custom Linux MOTD Screen
Creating a custom Message of the Day (Linux MOTD) screen on Linux involves modifying certain files and configurations. We’ll use the /etc/update-motd.d/
directory to add scripts that fetch and display relevant information.
Here’s the detailed procedure:
Step 1: Access the Terminal and Check MOTD is installed
Open a terminal on your Linux system.
sudo apt-get install --reinstall update-motd
Step 2: Backup Existing Linux MOTD and Update Scripts (Optional)
Backup the existing MOTD file and update scripts:
The Message of the Day (MOTD) in Linux is typically stored in the “/etc/motd” file. In some versions of Ubuntu and Debian, it’s located in “/etc/update-motd.d”.
sudo cp /etc/motd /etc/motd_backup
sudo cp -r /etc/update-motd.d/ /etc/update-motd.d_backup
Step 3: Create Custom Linux MOTD Scripts
Create custom scripts in the /etc/update-motd.d/
directory to fetch and display dynamic information. For example, create a script named 10-custom-info
:
sudo nano /etc/update-motd.d/10-custom-info
Add the following content to the script:
#!/bin/bash
# Fetch system information
WHO=$(who)
CPU=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}')
DISK=$(df -h / | awk 'NR==2 {print $5}')
RAM=$(free -m | awk 'NR==2 {print $3}')
# Display information
echo "Welcome to Your Custom MOTD"
echo "============================="
echo "Who is logged on: $WHO"
echo "CPU Usage: $CPU%"
echo "Disk Usage: $DISK"
echo "RAM Usage: $RAM MB"
Save the script and make it executable:
sudo chmod +x /etc/update-motd.d/10-custom-info
Need inspiration? Check out this MOTD Creator.
Step 4: Edit the MOTD File
Edit the main MOTD file to include a reference to the custom scripts:
sudo nano /etc/motd
Add the following line at the end of the file:
cat /etc/update-motd.d/10-custom-info
Step 5: Save and Exit
Save the MOTD file and exit the text editor.
Step 6: Test the MOTD
Log out and log back in, or open a new terminal window. Your custom MOTD with dynamic system information should now be displayed.
Step 7: Optional – Update MOTD
Some systems may require you to update the MOTD manually:
sudo update-motd
Now, each time a user logs in, they’ll see dynamic system information in the MOTD, including who is logged on, CPU usage, disk usage, and RAM usage. Feel free to customize the script further to include additional information if needed.
Q&A
Q1: What is Linux MOTD and why is it important?
A1: The Linux MOTD, or Message of the Day, is a customizable screen that users see when they log into a Linux system. It serves as a welcoming message and can convey important information, updates, or announcements. Customizing the MOTD allows system administrators to provide users with relevant details at login.
Q2: How can I create a custom MOTD in Linux?
A2: Creating a custom MOTD involves editing the MOTD file or using scripts in the /etc/update-motd.d/ directory. To make the login experience unique, you can add personalized messages, ASCII art, and even dynamic system information. Check out our detailed guide for step-by-step instructions.
Q3: Can I include dynamic system information in my Linux MOTD?
A3: Absolutely! You can enhance your MOTD by adding dynamic details like who is currently logged on, CPU usage, disk space, and RAM statistics. Utilizing scripts in the /etc/update-motd.d/ directory allows you to fetch and display real-time information for users.
Q4: Why should I consider customizing the MOTD for SEO benefits?
A4: Customizing the MOTD not only enhances user experience but can also positively impact SEO. Including relevant keywords in your custom messages and regularly updating the MOTD with fresh content can contribute to improved search engine visibility for your Linux-related content.
Q5: Are there any best practices for optimizing the Linux MOTD for SEO?
A5: Absolutely! To optimize your Linux MOTD for SEO, ensure that your custom messages contain keywords related to Linux, MOTD, and any specific topics you want to highlight. Regularly update the content to keep it relevant, and consider incorporating links to relevant pages or resources within your system.
Q6: Can I track the performance of my customized Linux MOTD for SEO?
A6: Yes, you can track the performance of your customized MOTD by monitoring user engagement and analyzing web traffic. Utilize analytics tools to measure the impact of your Linux MOTD on user interaction and adjust your content strategy accordingly for continuous SEO improvement.
Thats it, hope you have fun writing your own custom MOTD. Like our Linux Procedures? Check out more here.
Recent Comments