Objective

The objective is to permanently disable a last login message after user terminal or ssh login on Redhat Linux. Example:
$ ssh This email address is being protected from spambots. You need JavaScript enabled to view it.
	
This email address is being protected from spambots. You need JavaScript enabled to view it.'s password: 
Last login: Tue Dec  6 11:23:11 2016 from 10.1.1.3
rhel linux last login message disable or clear

Requirements

Privileged access to your Redhat Linux server.

Difficulty

EASY

Conventions

  • # - requires given command to be executed with root privileges either directly as a root user or by use of sudo command
  • $ - given command to be executed as a regular non-privileged user

Instructions

Single user

To permanently suppress a Last Login message as per on user basis, create a hidden .hushlogin file inside a user's home directory. For example to suppress a Last Login message for a linuxconfig user run:
# touch /home/linuxconfig/.hushlogin
Similarly to suppress a Last Login message for a root user run:
# touch /home/root/.hushlogin

System wide

To permanently suppress a Last Login message for the entire system, first empty /var/log/lastlog file:
# > /var/log/lastlog
The above will clear all last login information. To make the change permanent disable write access to this file:
# chattr +i /var/log/lastlog

Clear last logins and bad login attempts

Optionally you can clear all login and bad login attempts information which is displayed by use of last and lastb commands. To do so run:
# >/var/log/wtmp
# >/var/log/btmp
Make the above file immutable if you wish the system to stop storing this information permanently:
 # chattr +i /var/log/wtmp /var/log/btmp
rhel linux last login message disabled