Change the Terminal Message of the Day in Mac OS X
Whenever you launch the Terminal in Mac OS X, you may get a little message: “Welcome to Darwin!” or a “Last Login” time – well, after you’ve seen it a few hundred times you might be sick of it, or perhaps you’d prefer something more amusing, meaningful, or even useful to yourself and other computer users. That little message you’re seeing is the MOTD, otherwise called a Message of the Day, and it’s a simple text file located at /etc/motd.
We will show you how to change the MOTD in the Mac OS X Terminal to whatever you want, easily.
Checking the Current MOTD
Launch the Terminal and type:
$ cat /etc/motd
Unless you have already customized it, “Welcome to Darwin!” or the “Last Login” message will be what appears, depending on your version of OS X. Another option is if the /etc/motd file does not exist (which for many modern versions of OS X is the default case now), then nothing would appear except for the login details. But we don’t want that anymore, we want our very own motd message when a new terminal is launched, so here’s how to turn it into whatever you want.
How to Modify the Message of the Day (MOTD) to a Custom Message
Type the following into the command line, this will open the motd into nano, if you want to use another text editor like vim, that’s OK too:
sudo nano /etc/motd
nano is nothing more than a command line text editor, and works just like one. Line over and delete the text and type whatever you want in its place.
Let’s say we’ll place the message “Hello from OSXDaily.com!”
To save the changed MOTD file, you’ll hit control-O, and then hit return. That’s it. Then hit Control+X to exit out of nano editor.
Now when you launch the Terminal you’ll be greeted with your new message, in this case it may look like the following:
Hello from OSXDaily.com!
Mac~$
You can also choose to redirect output of a command to the motd file, including bash scripts or an existing command. For example, you could output uname or sw_vers like so:
sw_vers > /etc/motd
That would make the MOTD in OS X tell you the name, version, and build upon login, like so:
ProductName: Mac OS X
ProductVersion: 10.12.4
BuildVersion: 17F212
MacBook:~ User$
You can get as complicated or as simple as you want.
Note: Some users will be required to run nano as root, depending on their account privileges or what they’re logged into, this is done via the sudo command. Using the sudo command will prompt you for the administrators password. The appropriate sudo prefixed syntax would be:
$ sudo nano /etc/motd
The rest of the modification is the same.
If you want to remove the customized motd, just delete it from the /etc/motd file, or create a ‘.hushlogin’ file in the users root directory.
Last login: Tue Mar 29 08:45:38 on ttys005
The common zebra is an African equid best known for its beautiful, luxurious and
distinctive black and white stripes. Its stripes come in different patterns
unique to each individual, much like a snowflake. It is generally a pleasant and
social creature that lives in small harems to large herds. Unlike its closest
relatives, the horse and the ass, the zebra has never truly been domesticated.
SAMsDesktop:~ PsuedoDagan$ echo yes.
yes.
After rebooting the old message reappears. Any ideas?
Make a c++ unix executable to launch on start up:
nano zebra.cpp
#include
using namespace std;
int main(){
system(“cp ~/motd /etc/motd”);//enable root user
return 0;
}
^x
c++ zebra.cpp -o zebra
nano motd
The common zebra is an African equid best known for its beautiful, luxurious and
distinctive black and white stripes. Its stripes come in different patterns
unique to each individual, much like a snowflake. It is generally a pleasant and
social creature that lives in small harems to large herds. Unlike its closest
relatives, the horse and the ass, the zebra has never truly been domesticated.
^x
Then go to system preferences and make it run on start up.
It better be about f***ing zebras.
I tried this to get rid of a persistent Terminal message… and so following this tip did actually work and added my text line, BUT I still have this lingering line of text “You have mail.” in any new Terminal window… Any one know how to get rid of it or why its there… :-(
Thnx
MOKA
If there is a /var/mail/ remove it after catting the contents.
[…] you want to, you can create a custom MOTD with whatever message you want that will be displayed […]
Too late for sully, but here’s how to undo “touch .hushlogin” to get back the “Last login”
line at the start of each terminal session.
If you used “touch .hushlogin” command to remove the “Last login…” info, which shows up at each login to terminal, you can restore the “Last login” info by deleting the invisible .hushlogin file, located in your home folder.
One way to do this is to open terminal and type “rm ~/.hushlogin” (without the quotes, of course!) $ rm ~/.hushlogin
~/.hushlogin actually prevents the system from displaying /etc/motd during your logins. You can still put your own login customizations into ~/.profile if you wish, for example…
$ sudo vi ~/.profile
Edit this like a regular bash script and use echo to display what you wanted in your motd.
ok. i customized the motd, it worked fine. but then i used “touch .hushlogin” to remove the “Last Login…” info from showing up every time i start Terminal. It worked in removing the “Last Login…” info, but it also has stopped my motd from displaying. any help in undoing hushlogin would be greatly appreciated. i just want the motd to come back upon launch.
In case anyone is still wondering, this how to get rid of the “Last login:” message. Run `touch .hushlogin` in your home folder.
Joel,
‘sudo nano’ is a command that runs the nano text editor as the super user root (or system administrator), thus allowing you to edit the /etc/motd file
hi, could any one tell me What “Sudo nano” means?
Thanks
is there a way to get rid of the “last login” message as well?
Thanks, Ivan. I suspected I needed to type sudo before the command, but I wasn’t sure.
Mario,
I don’t think you’re alone. Try adding the ‘sudo’ command to the sequence in front of nano. This would make the new command be:
sudo nano /etc/motd
It will prompt you for the administrator password, which allows you to edit the file by running nano as root. Hope that helps you and others.
Also, you can quit nano by hitting control-X
It didn’t work for me. I get the message “Could not open file for writing: Permission denied”. Do I have to be logged in as root? I have admin privileges with my regular login.
Hah…it’s great…i changed it to “don’t terminate my terminal”….
another great tip!