Most of us will be using ssh to log into our raspberry pi. So lets change the motd to something more shiny:
1 sudo nano /etc/motd
delete everything
1 sudo nano /etc/init.d/motd
look for uname -snrvm > /var/run/motd.dynamic and comment it out (put # at the beginning of the line)
1 sudo nano /etc/ssh/sshd_config
look for PrintLastLog and change yes to no
1 sudo nano /etc/motd.tcl
azeam of raspberrypi.org forums provided a nice code which shows some basic information of your raspberry pi and can be complete customized. You’ll also find information about customized motd’s at the following link http://www.mewbies.com/how_to_customize_your_console_login_message_tutorial.htm
so lets put in the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
#!/usr/bin/env tclsh # MOTD script original? / mod mewbies.com # * Variables set var(user) $env(USER) set var(path) $env(PWD) set var(home) $env(HOME) # * Check if we're somewhere in /home #if {![string match -nocase "/home*" $var(path)]} { if {![string match -nocase "/home*" $var(path)] && ![string match -nocase "/usr/home*" $var(path)] } { return 0 } # * Calculate last login set lastlog [exec -- lastlog -u $var(user)] set ll(1) [lindex $lastlog 7] set ll(2) [lindex $lastlog 8] set ll(3) [lindex $lastlog 9] set ll(4) [lindex $lastlog 10] set ll(5) [lindex $lastlog 6] # * Calculate current system uptime set uptime [exec -- /usr/bin/cut -d. -f1 /proc/uptime] set up(days) [expr {$uptime/60/60/24}] set up(hours) [expr {$uptime/60/60%24}] set up(mins) [expr {$uptime/60%60}] set up(secs) [expr {$uptime%60}] # * Calculate usage of home directory set usage [lindex [exec -- /usr/bin/du -ms $var(home)] 0] # * Calculate SSH logins: set logins [lindex [exec -- who -q | cut -c "9-11"] 0] # * Calculate processes set psu [lindex [exec -- ps U $var(user) h | wc -l] 0] set psa [lindex [exec -- ps -A h | wc -l] 0] # * Calculate current system load set loadavg [exec -- /bin/cat /proc/loadavg] set sysload(1) [lindex $loadavg 0] set sysload(5) [lindex $loadavg 1] set sysload(15) [lindex $loadavg 2] # * Calculate Memory set memory [exec -- free -m] set mem(t) [lindex $memory 7] set mem(u) [lindex $memory 8] set mem(f) [lindex $memory 9] set mem(c) [lindex $memory 16] set mem(s) [lindex $memory 19] # * ascii berry set head { .~ .~~~..~. _ _ : .~.'~'.~. : ___ ___ ___ ___| |_ ___ ___ ___ _ _ ___|_| ~ ( ) ( ) ~ | _| .'|_ -| . | . | -_| _| _| | | | . | | ( : '~'.~.'~' : ) |_| |__,|___| _|___|___|_| |_| |_ | | _|_| ~ .~ ( ) ~. ~ |_| |___| |_| ( : '~' : ) '~ .~~~. ~' '~'} # * ascii leaf set head2 { .~~. .~~. '. \ ' ' / .'} # * display kernel version set uname [exec -- /bin/uname -snrvm] set unameoutput0 [lindex $uname 0] set unameoutput [lindex $uname 1] set unameoutput2 [lindex $uname 2] set unameoutput3 [lindex $uname 3] set unameoutput4 [lindex $uname 4] # * display temperature set temp [exec -- /opt/vc/bin/vcgencmd measure_temp | cut -c "6-9"] set tempoutput [lindex $temp 0] # * display GPU version set gpu [exec -- /opt/vc/bin/vcgencmd version] set gpuoutput [lindex $gpu 0] set gpuoutput1 [lindex $gpu 1] set gpuoutput2 [lindex $gpu 2] set gpuoutput3 [lindex $gpu 8] set gpuoutput4 [lindex $gpu 9] # * Print Results puts "\033\[01;32m$head2\033\[0m" puts "\033\[02;31m$head\033\[0m" puts " System........: $unameoutput0 $unameoutput $unameoutput2 $unameoutput3 $unameoutput4" puts " GPU Version...: $gpuoutput $gpuoutput1 $gpuoutput2, $gpuoutput3 $gpuoutput4" puts " Last Login....: $ll(1) $ll(2) $ll(3) $ll(4) from $ll(5)" puts " Uptime........: $up(days)days $up(hours)hours $up(mins)minutes $up(secs)seconds" puts " Temperature...: $tempoutput°C" puts " Load..........: $sysload(1) (1minute) $sysload(5) (5minutes) $sysload(15) (15minutes)" puts " Memory MB.....: Total: $mem(t) Used: $mem(u) Free: $mem(f) Cached: $mem(c) Swap: $mem(s)" puts " Disk Usage....: You're using ${usage}MB in $var(home)" puts " SSH Logins....: Currently $logins user(s) logged in." puts " Processes.....: You're running ${psu} which makes a total of ${psa} running" if {[file exists /etc/changelog]&&[file readable /etc/changelog]} { puts " . .. More or less important system informations:\n" set fp [open /etc/changelog] while {-1!=[gets $fp line]} { puts " ..) $line" } close $fp puts "" } |
save and go on with the next step:
1 sudo chmod 755 /etc/motd.tcl
1 sudo nano /etc/profile
go to the end of the file an add /etc/motd.tcl
save your work and test it
1 /etc/motd.tcl
You’ll see I just added a custom text at the bottom, you can modify it however you like by editing /etc/motd.tcl
1 sudo nano /etc/motd.tcl