Thursday, 30 January 2014

Removing / Modifying login message, motd (message of the day)

When you first open a terminal on osx you get's what is called the motd - message of the day, by default it displays the last login information. This is useful for server type setups where you have multiple people logging into different machines and reading the motd, but it isn't really necessary in a person computer type situation.

This simple tutorial will show you how to change the motd or completely remove it.

Prerequisites

This can be done on a base os x machine (no pre installed software required)

This tutorial was done with the following versions:
  • Mavericks (10.9)

Configuration - To Remove

1. open up a terminal and observe the motd

Displays the last login information

2. enter this command
touch ~/.hushlogin
touch .hushlogin


This creates an empty hidden file (note the dot in front of the filename) that the system looks for at login of the terminal to determine if it should run the motd.

3. close the terminal and open it up again

goodbye annoying motd

That annoying login message is now gone. Hooray.


Configuration - To Add

Maybe you like having a login message, that's fine, let's change it. 

1. run the following command

sudo nano /etc/motd

/etc/motd is the file we need to edit

2. Write any welcome message you want in this empty file

My motd message

3. Save the file then close and open your terminal

Note: If you did the previous part of the tutorial you'll need to delete the .hushlogin file stored in the root of your home directory. sudo rm -f ~/.hushlogin should do the trick.


Your new login message.


This is a very simple way to a message at login at the terminal. There are more interesting things you can do with login messages such as displaying dynamic information (such as system information or random quotations) but that is a bit beyond the scope of this tutorial.

End Notes

Check out some other OSX tutorials:

  • How to change Terminal prompt ($PS1)
  • Awesome command line applications
  • Useful scripts / configurations for OSX