Objective – How to disable Ubuntu motd (message of the day) login message.

On Ubuntu machine there is motd (message of the day) comes when we login. Might in some case it usable, but i want to remove this motd Welcome message.Let’s see how we can remove login message on Ubuntu 18.04 Machine.

SetUP

OS – Ubuntu
version – Ubuntu 18.04.4

ssirohi@wks:~$ lsb_release -d       
Description:    Ubuntu 18.04.4 LTS  

So i have installed one Ubuntu Machine and when i tried to login on it, i get below login message.

Ubuntu 18.04.4 LTS wks ttyS0                                             
                                                                         
wks login: root                                                          
Password:                                                                
Last login: Wed May 13 14:43:15 UTC 2020 on ttyS0                        
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-99-generic x86_64)       
                                                                         
 * Documentation:  https://help.ubuntu.com                               
 * Management:     https://landscape.canonical.com                       
 * Support:        https://ubuntu.com/advantage                          
                                                                         
  System information as of Wed May 13 22:48:32 UTC 2020                  
                                                                         
  System load:  0.0               Processes:           93                
  Usage of /:   52.0% of 3.87GB   Users logged in:     0                 
  Memory usage: 7%                IP address for ens3: 192.168.122.208   
  Swap usage:   0%                                                       
                                                                         
                                                                         
6 packages can be updated.                                               
4 updates are security updates.                                                                                                    
root@wks:~#                                                              
root@wks:~#                                                              

By-default most Linux/Unix machine has /etc/motd file that act has login message file which will print as it contain when anyone login on machine interactively. But in Ubuntu there is complete set of script to cover this part bit which make more easy and flexible to manage which make it quit useful as well.

I want to disable this message completely. If you investigate a bit, there is man page for update-motd ,which has all details for it.

man update-motd

As per this we have /etc/update-motd.d which contain various scripts that use to execute to get these messages. We can read these scripts and change and create out own script to create dynamic login message.

Let’s first see, how we can disable this message, because these are script and script need execute permission for work as executable. SO if we remove its executable permission, we can get rid of it.

Remove execute permission of /etc/update-motd.d/

So to disable Ubuntu motd message we have to remove executable permission from all file and link present inside /etc/update-motd.d.

chmod -R 644 /etc/update-motd.d

We can remove individual file permission in case we just need to remove specific kind of message coming through scripts inside this directory, like

chmod 644 /etc/update-motd.d/90-updates-available

Please check it once because it also has one link file, for that you have to change permission from source file. After removing permission, it should be like.

root@wks:~# ll /etc/update-motd.d                                                                               
total 60                                                                                                        
drw-r--r--  2 root root 4096 May 13 12:44 ./                                                                    
drwxr-xr-x 95 root root 4096 May 13 14:45 ../                                                                   
-rw-r--r--  1 root root 1220 Apr  9  2018 00-header                                                             
-rw-r--r--  1 root root 1157 Apr  9  2018 10-help-text                                                          
lrwxrwxrwx  1 root root   46 May 13 12:43 50-landscape-sysinfo -> /usr/share/landscape/landscape-sysinfo.wrapper
-rw-r--r--  1 root root 4646 Sep 27  2019 50-motd-news                                                          
-rw-r--r--  1 root root  604 Mar 21  2018 80-esm                                                                
-rw-r--r--  1 root root 3017 Mar 21  2018 80-livepatch                                                          
-rw-r--r--  1 root root   97 Nov 12  2018 90-updates-available                                                  
-rw-r--r--  1 root root  299 Jun  3  2019 91-release-upgrade                                                    
-rw-r--r--  1 root root  165 Nov 25 15:23 92-unattended-upgrades                                                
-rw-r--r--  1 root root  129 Nov 12  2018 95-hwe-eol                                                            
-rw-r--r--  1 root root  111 Sep 20  2018 97-overlayroot                                                        
-rw-r--r--  1 root root  142 Nov 12  2018 98-fsck-at-reboot                                                     
-rw-r--r--  1 root root  144 Nov 12  2018 98-reboot-required                                                    

Once we done so, login message is no more visible on login.

                                                  
Ubuntu 18.04.4 LTS wks ttyS0                      
                                                  
wks login: root                                   
Password:                                         
Last login: Wed May 13 23:13:28 UTC 2020 on ttyS0 

We can create our own executable file and place it same directory with name like 99-custome-message to display on login time.

With above discussion, now we know how we can remove login message from Ubuntu machine.