Thursday, February 10, 2011

A Simple Bash script to see the login information.

This is the script.

 #!/bin/bash  
for user in `ls -al /home | awk '{ print $9 }'`
do
echo $user
last -f /var/log/wtmp.1 -1 $user | head -1
last -1 $user | head -1
done


And, this is the output.

 bxxxx  
bxxxx pts/0 wireless1x............ Thu Jan 27 15:56 - 16:06 (00:09)
bxxxx pts/0 wireless1x-15-20 Tue Feb 1 11:44 - 12:19 (00:35)