Linux LAST Login Admin Details Script

Linux Last searches back through the file /var/log/wtmp (or the file designated by the -f flag) and displays a list of all users logged in (and out) since that file was created. Names of users and tty’s can be given, in which case last will show only those entries matching the arguments. Names of ttys can be abbreviated, thus last 0 is the same as last tty0.

Last searches back through the file /var/log/wtmp (or the file designated by the -f flag) and displays a list of all users logged in (and out) since that file was created. Names of users and tty’s can be given, in which case last will show only those entries matching the arguments. Names of ttys can be abbreviated, thus last 0 is the same as last tty0.

When last catches a SIGINT signal (generated by the interrupt key, usually control-C) or a SIGQUIT signal (generated by the quit key, usually control-\), last will show how far it has searched through the file; in the case of the SIGINT signal last will then terminate.

The pseudo user reboot logs in each time the system is rebooted. Thus last reboot will show a log of all reboots since the log file was created.

Basically I have a 3 request from customer as below:

  • display a list of users that have not been login after X days.
  • lock the users that have not been login after X days.
  • delete a users that have not been login after X days.

First, the script will search for UID > 999 then it can use to display the result, lock the user account and delete the user account which I make a remarks.

The original script can be found on Unix forums which I have make a small modification.

#Script START here 

Read more

Possibly Related Posts:


Planet Malaysia

  • Follow us on Twitter


  • web www.planetmy.com