Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding unused user accounts

Status
Not open for further replies.

henderj99

Programmer
Nov 11, 2002
4
US
is there some tool i can use to find user accounts that haven't been used for six months/1 year?

i was thinking of a script using "finger" but i'm not sure that will work.
 
finger should give you last login information and perhaps you could parse this to read the date and compare it with a date you specify? Not easy, but possible I guess. You could try posting for advice in the Unix Scripting forum. Cheers.
 
You can combine listusers with finger:

listusers |awk '{ print $1 }' > list.txt #(this gives you the list of non-default users on the syste)
cat list.txt | while read LINE
do
finger $LINE >> finger.txt # This runs finger on all the non-default users.
done
awk '/Login/{print;getline;getline;print;}' finger.txt > final.txt # This gives you the login name line, login times (or never logged in).
rm finger.txt

I haven't figured out actually pulling out the names of the folks who haven't logged in in 6 months/1 year.
 
Thanks for your replies ALL! I eventually found out that there's a file called "loginlog" that lists the username and last login date. Right now I'm not sure if this a product of the application on my box or a UNIX feature but it solved my problem.

Again, THANKS MUCH!
 
The 'last' command gives all login history of all users.

last <username> | head -n1 will give you the last time that a user logged into the system.

One caveat - if the user has not logged in within the last year and the wtmp file has not been reset in that time, you may get a false positive. The last command does not report the year and you might show the user having logged in recently, but it's actually from over a year ago.

Geoff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top