How to remove the “Last login..” message from the shell

By

Learn how to remove the annoying 'Last login...' message that shows when you open your shell by creating a .hushlogin file, on both macOS and Linux.

~~~

To remove the “Last login…” message from your shell, create an empty file called .hushlogin in your home folder. That’s the whole fix. Let me explain what’s going on.

My shell had this line every time I opened it:

Before

Useless information for me.

And I wanted to remove it.

Where does that message come from?

That line is not printed by your shell. It’s printed by the login program, which runs right before your shell starts.

On macOS, the Terminal app starts every new window and tab as a login shell. So login runs each time, and each time it prints when you last logged in, and from where.

That made sense decades ago, on shared machines. Seeing an unexpected login time could reveal someone else had used your account. On your own laptop, where you open dozens of terminal tabs a day, it’s just noise.

How to remove it

The login program checks for a file called .hushlogin in your home folder. If the file exists, it stays quiet.

The file can be empty, so touch is all you need:

touch ~/.hushlogin

Open a new terminal window and the message is gone:

After

Works in macOS and Linux. On Linux the same file also silences the message of the day at console login, and it works when you SSH into a server too, since sshd checks for it as well.

If you ever want the message back, delete the file:

rm ~/.hushlogin

Still seeing the message?

Be careful with where you create the file. It must live in the home folder of the user that logs in, not in some project folder.

If you created it while in another directory with touch .hushlogin, that’s the problem. The ~/ prefix in the command above makes sure it lands in your home folder, whatever your current directory is.

Tagged: CLI · All topics
~~~

Related posts about cli: