How to disable ‘Last Login’ welcome message in Linux

last login message

When you log into a Linux system, especially via SSH, you might notice a message displaying the time and date of your last login. This feature, while useful for tracking access and detecting unauthorized logins, may not be necessary for everyone. Some users prefer a cleaner terminal interface without distractions.

In this guide, we’ll show you how to disable the last login message either for individual users or across the entire system.

Why Disable the Last Login Message?

The last login message serves an important purpose: it alerts users to the time and date of their previous login, which can signal if someone else has accessed their account. However, in certain scenarios, this feature might not be needed:

  • Minimalist environments: Users who want an uncluttered terminal may prefer to remove all non-essential messages.
  • Test environments: In testing or sandbox systems, this message can be redundant.
  • Shared systems: For environments where multiple users frequently log in and out, the message might not add much value.

Whether you fall into one of these categories or have your reasons, disabling the message is straightforward.

Disable the Last Login Message for a Single User

To turn off this message for an individual user:

  1. Log in to the terminal as the specific user.
  2. Create a hidden .hushlogin file in their home directory by running: touch ~/.hushlogin This empty file acts as a flag for the system to suppress the last login message. If you ever want to re-enable the message, simply delete this file: rm ~/.hushlogin

Disable the Last Login Message System-Wide

To turn off the last login message for all users:

  1. Open the SSH configuration file: sudo nano /etc/ssh/sshd_config
  2. Locate the line that reads: #PrintLastLog yes Remove the # to uncomment it, and change yes to no: PrintLastLog no
  3. Save and exit the file.
  4. Apply the changes by restarting the SSH service: sudo systemctl restart sshd

This update applies globally, ensuring no user sees the last login message when connecting to the system.

See also  Find the CPU (processor) speed and model under Linux

Does Disabling the Message Impact Security?

Disabling this message does remove a quick and easy way to spot unauthorized access. For example, if you notice a login timestamp you don’t recognize, it could signal someone else accessed your account. Removing this notification means you’ll need to rely on other methods to monitor access, such as reviewing system logs (/var/log/auth.log on Debian-based systems or /var/log/secure on Red Hat-based systems).

However, for non-critical systems or environments where security isn’t a top concern, disabling this feature can simplify your login experience.

Additional Tips

  • Check the Logs: Even if you disable the message, you can still review login activity using commands like: last This command shows a detailed list of user logins, including dates, times, and IP addresses.
  • Automate Changes: For system administrators managing multiple systems, you can automate these changes using configuration management tools like Ansible or a simple shell script.

FAQs

Why would I want to disable the last login message?

You might prefer a cleaner terminal interface or work in an environment where the message is unnecessary, like a testing server or shared system.

Does disabling the last login message affect performance?

No, the message is purely informational and doesn’t impact system performance. Removing it simply prevents it from displaying during login.

How do I re-enable the message?

For individual users, delete the .hushlogin file: rm ~/.hushlogin

2 thoughts on “How to disable ‘Last Login’ welcome message in Linux”

  1. It’s worth noting that the “last login” message is there so people can get tipped off if someone else has obtained their password.

    .hushlogin has its uses but if the last login doesn’t match with when I last used a system I know it’s time to get worried.

  2. Finally I’ve get rid off this stupid msg. NICE, tried a few other ways, but did not work. Thanks!

Leave a Comment