Disable Last Login Message on Linux using hushlogin

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 the linuxconfig user, we would run this command:

$ sudo touch /home/linuxconfig/.hushlogin

Similarly to suppress a Last Login message for the root user, we would run this command:

$ sudo touch /root/.hushlogin

System wide

Note: you will need to login to your system’s root account in order to run these commands. 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

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

Src: https://linuxconfig.org/how-to-disable-last-login-message-on-rhel-linux

Share

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.