Last active
August 10, 2026 13:44
-
-
Save kibotu/62a0590a46f28522255472f47764a178 to your computer and use it in GitHub Desktop.
RaspberryPI Status on ssh connect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Uptime | |
| upSeconds=$(cut -d. -f1 /proc/uptime) | |
| days=$((upSeconds / 86400)) | |
| hours=$((upSeconds / 3600 % 24)) | |
| mins=$((upSeconds / 60 % 60)) | |
| secs=$((upSeconds % 60)) | |
| UPTIME=$(printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs") | |
| # Load averages | |
| read one five fifteen _ < /proc/loadavg | |
| # Memory | |
| MEM_FREE=$(awk '/MemAvailable:/ {print $2}' /proc/meminfo) | |
| MEM_TOTAL=$(awk '/MemTotal:/ {print $2}' /proc/meminfo) | |
| # Running processes | |
| PROCESSES=$(ps -e --no-headers | wc -l) | |
| # CPU temperature | |
| if command -v vcgencmd >/dev/null 2>&1; then | |
| CPU_TEMP=$(vcgencmd measure_temp | cut -d= -f2) | |
| else | |
| CPU_TEMP="N/A" | |
| fi | |
| # Disk space | |
| DISK_SPACE=$(df -h / | awk 'NR==2 {print $4 " of " $2}') | |
| # IP addresses | |
| LOCAL_IP=$(hostname -I | awk '{print $1}') | |
| if command -v curl >/dev/null 2>&1; then | |
| PUBLIC_IP=$(curl -4 -fs --max-time 3 https://api.ipify.org 2>/dev/null) | |
| elif command -v wget >/dev/null 2>&1; then | |
| PUBLIC_IP=$(wget -qO- https://api.ipify.org 2>/dev/null) | |
| else | |
| PUBLIC_IP="N/A" | |
| fi | |
| PUBLIC_IP=${PUBLIC_IP:-N/A} | |
| # Output | |
| echo "$(tput setaf 2) | |
| .~~. .~~. $(date '+%A, %e %B %Y, %X %Z') | |
| '. \ ' ' / .' $(uname -srmo)$(tput setaf 1) | |
| .~ .~~~..~. | |
| : .~.'~'.~. : Uptime.............: ${UPTIME} | |
| ~ ( ) ( ) ~ Memory.............: ${MEM_FREE}kB (Available) / ${MEM_TOTAL}kB (Total) | |
| ( : '~'.~.'~' : ) Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min) | |
| ~ .~ ( ) ~. ~ Running Processes..: ${PROCESSES} | |
| ( : '~' : ) CPU Temperature....: ${CPU_TEMP} | |
| '~ .~~~. ~' Free Disk Space....: ${DISK_SPACE} | |
| '~' IP Addresses.......: ${LOCAL_IP} and ${PUBLIC_IP} | |
| $(tput sgr0)" | |
| # Load user's bash configuration | |
| if [ -f ~/.bashrc ]; then | |
| source ~/.bashrc | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Login banner for a regular Linux machine (SSH or local login) | |
| # Adapted from the classic Raspberry Pi ".bash_profile" banner: | |
| # - swaps vcgencmd (RPi-only) for a generic /sys/class/thermal read | |
| # - detects the root filesystem instead of assuming /dev/root | |
| let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)" | |
| let secs=$((${upSeconds}%60)) | |
| let mins=$((${upSeconds}/60%60)) | |
| let hours=$((${upSeconds}/3600%24)) | |
| let days=$((${upSeconds}/86400)) | |
| UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"` | |
| # get the load averages | |
| read one five fifteen rest < /proc/loadavg | |
| # CPU temperature (generic - not every machine exposes this, especially VMs/CI hosts) | |
| CPU_TEMP="" | |
| # 1) lm-sensors, if installed | |
| if command -v sensors >/dev/null 2>&1; then | |
| CPU_TEMP=$(sensors 2>/dev/null | grep -m1 -E 'Package id 0|Tctl|Tdie|Composite|CPU' | grep -oE '[+-][0-9]+\.[0-9]+°C' | head -1) | |
| fi | |
| # 2) any thermal zone under /sys, not just zone0 (order/availability varies by kernel) | |
| if [ -z "$CPU_TEMP" ]; then | |
| for zone in /sys/class/thermal/thermal_zone*/temp; do | |
| [ -f "$zone" ] || continue | |
| raw=$(cat "$zone" 2>/dev/null) | |
| [ -n "$raw" ] && [ "$raw" -gt 0 ] 2>/dev/null || continue | |
| CPU_TEMP=$(awk -v t="$raw" 'BEGIN{printf "+%.1f°C", t/1000}') | |
| break | |
| done | |
| fi | |
| # 3) hwmon coretemp/k10temp, if present (common on bare-metal servers, no lm-sensors installed) | |
| if [ -z "$CPU_TEMP" ]; then | |
| for hwmon in /sys/class/hwmon/hwmon*/temp1_input; do | |
| [ -f "$hwmon" ] || continue | |
| raw=$(cat "$hwmon" 2>/dev/null) | |
| [ -n "$raw" ] && [ "$raw" -gt 0 ] 2>/dev/null || continue | |
| CPU_TEMP=$(awk -v t="$raw" 'BEGIN{printf "+%.1f°C", t/1000}') | |
| break | |
| done | |
| fi | |
| CPU_TEMP=${CPU_TEMP:-"n/a (no sensor exposed - common on VMs/CI hosts)"} | |
| # memory, human readable (kB -> GiB, one decimal place) | |
| MEM_AVAIL=$(awk '/MemAvailable/ {printf "%.1fG", $2/1024/1024}' /proc/meminfo) | |
| MEM_TOTAL=$(awk '/MemTotal/ {printf "%.1fG", $2/1024/1024}' /proc/meminfo) | |
| # root filesystem free space (works whether root is /dev/sda1, /dev/nvme0n1p2, etc.) | |
| ROOT_FS=$(df -Ph / | awk 'NR==2 {print $4 " of " $2}') | |
| # public IP (best effort, times out fast so it doesn't hang your login) | |
| PUBLIC_IP=$(curl -s --max-time 2 https://icanhazip.com 2>/dev/null || echo "n/a") | |
| GREEN="$(tput setaf 2)" | |
| RED="$(tput setaf 1)" | |
| RESET="$(tput sgr0)" | |
| ART_WIDTH=19 # fixed column width for the face art, so labels always line up | |
| echo "$GREEN" | |
| printf "%-${ART_WIDTH}s%s\n" " .~~. .~~. " "$(date +"%A, %e %B %Y, %X %Z")" | |
| printf "%-${ART_WIDTH}s%s${RED}\n" " '. \\ ' ' / .' " "$(uname -srmo)" | |
| printf "%s\n" " .~ .~~~..~." | |
| printf "%-${ART_WIDTH}s%s\n" " : .~.'~'.~. : " "Uptime.............: ${UPTIME}" | |
| printf "%-${ART_WIDTH}s%s\n" "~ ( ) ( ) ~ " "Memory.............: ${MEM_AVAIL} (Available) / ${MEM_TOTAL} (Total)" | |
| printf "%-${ART_WIDTH}s%s\n" "( : '~'.~.'~' : )" "Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min)" | |
| printf "%-${ART_WIDTH}s%s\n" " ~ .~ ( ) ~. ~ " "Running Processes..: $(ps ax | wc -l | tr -d " ")" | |
| printf "%-${ART_WIDTH}s%s\n" " ( : '~' : ) " "CPU Temperature....: ${CPU_TEMP}" | |
| printf "%-${ART_WIDTH}s%s\n" " '~ .~~~. ~' " "Free Disk Space....: ${ROOT_FS}" | |
| printf "%-${ART_WIDTH}s%s\n" " '~' " "IP Addresses.......: $(hostname -I | /usr/bin/cut -d " " -f 1) and ${PUBLIC_IP}" | |
| echo "$RESET" | |
| # Include .bashrc | |
| if [ -f ~/.bashrc ]; then | |
| source ~/.bashrc | |
| fi |
kibotu
commented
Jul 12, 2026
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment