Operating System - HP-UX
1833871 Members
1792 Online
110063 Solutions
New Discussion

Find unused logins script?

 
Ed McKnight
Advisor

Find unused logins script?

Hi,

Anyone have a quick script to skim passwd and find unused logins in wtmp?

Thanks
3 REPLIES 3
Simon Hargrave
Honored Contributor

Re: Find unused logins script?

cut -d: -f1 /etc/passwd | sort > allusers
will give a list of all users

last -f /var/adm/wtmp | cut -d" " -f1 | sort -u > usedusers

then

sdiff allusers usedusers

will show you the differences, and therefore which users haven't been used.
Rick Garland
Honored Contributor

Re: Find unused logins script?

Here is a quickie;

cat /etc/passwd | awk -F: '{print $1}' | while read line
do
last $line
done

This will parse each line of the passwd file, do the last command against the acct name and report the results.

Note: The results will only be as good as your wtmp file. Example, if the wtmp file is recreated monthly you will only get that months data.

You can add echo commands so you can see the acct name and so forth. Modify to your needs.

Ed McKnight
Advisor

Re: Find unused logins script?

Thanks simon,
I have results that I am wondering about...

rusgel <
ryaben ryaben
ryasaa | ryaobr
sadema sadema

rusgel
is unused I think
ryassa | ryaobr
Have me stumped
ryaben and sadema are loging in, right?

then there is this next thing
What or how did I get a right colum entry?
I left the line before and after for context.

jenpar jenpar
> jensch
jenste jenste