Linux Custom MOTD Guide

Install FIGlet

# Update package list
sudo apt update

# Install figlet
sudo apt install figlet -y

# Test
figlet AMUCTA

Create MOTD Script

# Create custom MOTD script
sudo nano /etc/update-motd.d/99-amucta

Make Script Executable

# Allow execution
sudo chmod +x /etc/update-motd.d/99-amucta
#!/bin/bash
clear

figlet -f slant AMUCTA

echo "Welcome to AMUCTA Production Server"
echo

Display Hostname

# Show server hostname
echo "Hostname : $(hostname)"

Display Date & Time

# Current server time
echo "Date : $(date)"

Display IP Address

# Primary server IP
IP=$(hostname -I | awk '{print $1}')
echo "IP Address : $IP"

Display CPU Usage

# CPU utilization
CPU=$(top -bn1 | grep "Cpu(s)" | awk '{print 100-$8"%"}')
echo "CPU Usage : $CPU"

Display RAM Usage

# Used / Total RAM
RAM=$(free -h | awk '/Mem:/ {print $3 " / " $2}')
echo "Memory : $RAM"

Display Swap Usage

# Used / Total Swap
SWAP=$(free -h | awk '/Swap:/ {print $3 " / " $2}')
echo "Swap : $SWAP"

Display Disk Usage

# Root filesystem usage
DISK=$(df -h / | awk 'NR==2 {print $3 " / " $2 " (" $5 ")"}')
echo "Disk : $DISK"

Display System Uptime

# Server uptime
echo "Uptime : $(uptime -p)"

Display System Load

# Load average
echo "Load : $(uptime | awk -F'load average:' '{print $2}')"

Display Running Processes

# Total running processes
echo "Processes : $(ps -e --no-headers | wc -l)"

Display Logged-in Users

# Number of active users
echo "Users : $(who | wc -l)"

Display Last Login

# Previous login
last -n 1 "$USER"

Preview the MOTD

# Test without logging out
run-parts /etc/update-motd.d/