Update Ubuntu 16.04 Login Message

The standard login message is called the MOTD and usually looks like this:

Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-116-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

29 packages can be updated.
11 updates are security updates.


Last login: Wed Jul 11 18:35:08 2018 from 555.555.555.555
[email protected]:~$

This text is generated by a series of executable files in /etc/update-motd.d that you can change or even add your to.

[email protected]:~$ ls -la /etc/update-motd.d
total 36
drwxr-xr-x  2 root root 4096 Jun  6 15:43 .
drwxr-xr-x 92 root root 4096 Jun 28 08:34 ..
-rwxr-xr-x  1 root root 1220 Oct 22  2015 00-header
-rwxr-xr-x  1 root root 1157 Jun 14  2016 10-help-text
-rwxr-xr-x  1 root root   97 May 24  2016 90-updates-available
-rwxr-xr-x  1 root root  299 Jul 22  2016 91-release-upgrade
-rwxr-xr-x  1 root root  111 Jan 11 05:42 97-overlayroot
-rwxr-xr-x  1 root root  142 May 24  2016 98-fsck-at-reboot
-rwxr-xr-x  1 root root  144 May 24  2016 98-reboot-required

I decided to modify mine to display the system’s IP addresses on login and disable 00-header, 10-help-text from running:

[email protected]:~$ ls -la /etc/update-motd.d
total 44
drwxr-xr-x  2 root root 4096 Jul 11 19:54 ./
drwxr-xr-x 91 root root 4096 Jul 11 16:59 ../
-r--r--r--  1 root root 1220 Oct 22  2015 00-header
-r--r--r--  1 root root 1157 Jun 14  2016 10-help-text
-rwxr-xr-x  1 root root  147 Jul 11 19:54 50-ip*
-rwxr-xr-x  1 root root   97 May 24  2016 90-updates-available*
-rwxr-xr-x  1 root root  299 Jul 22  2016 91-release-upgrade*
-rwxr-xr-x  1 root root  111 Jan 11 05:42 97-overlayroot*
-rwxr-xr-x  1 root root  142 May 24  2016 98-fsck-at-reboot*
-rwxr-xr-x  1 root root  144 May 24  2016 98-reboot-required*

As you can see, to disable a file you only need to remove the execute permissions. When you add a file it’s important to think about the order in which they’ll execute. These scripts are run alphabetically which is NOT the same as ‘numerical order’

 

Here’s the IP script I added.

#!/bin/bash
echo -e "\n\nSystem IP Addresses: "
ifconfig | grep "inet addr" | cut -d: -f2 | awk '/([0-9]{1,3}\.){3}[0-9]{1,3}/ { print "\t" $1; }'

Of course you’re could do anything in these scripts such as list the current load, free space, memory usage, logged on users, etc…

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑

%d bloggers like this: