Shell script to check login history in Linux


5 thoughts on “Shell script to check login history in Linux”

    • Store printf content to a log file and run this script using cron. You can adjust the cron value based on your requirement. For example to run everyday at 8 AM use 0 8 * * *

      Reply
  1. The script works well but a lot of lines with “grep: Invalid back reference” may be some problem with the version of egrep ? I’m on a Centos 7 machine

    Reply
    • This is to perform a IP to hostname lookup. We are using Google’s DNS to perform the lookup. Since my lab is in private network, I am getting NXDOMAIN, but if you do a lookup of a public IP then you should get proper hostname value. Or you can also use your own DNS (if any) to perform hostname lookup

      Reply

Leave a Comment

GoLinuxCloud Logo


We try to offer easy-to-follow guides and tips on various topics such as Linux, Cloud Computing, Programming Languages, Ethical Hacking and much more.

Programming Languages

JavaScript

Python

Golang

Node.js

Java

Laravel