Solved

How to list Inactive user account (AIX, SOLARIS, LINUX)

Posted on 2011-09-14
3
3,279 Views
Last Modified: 2013-12-04
Hi I need to find and list all inactive user account (45 days without logging) on aix, solaris and linux.

I have to disable all the inactive account.
0
Comment
Question by:cismoney
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 36535365
Hi,

the attached script should give you a start for AIX.

It lists how many days ago your users last logged in.

Please note that the script doesn't list users without a password (they cannot login anyway),
users with a userid less than 12 (those system-related ids should not be touched),
and the userid "nobody" (needed for several system purposes, e.g. lpd).

Have fun!

wmp
awk -F: '$2!="*"&&$3>11&&$1!="nobody" {print $1}' /etc/passwd |\
xargs -I{} lssec -f /etc/security/lastlog -s {} -a time_last_login 2>/dev/null |\
awk -v N=$(date +%s) -F" |=" '
 {if($3!="") {printf "%16s\t%s %.1f %s\n", $1, "last login", (N-$3)/(3600*24), "days ago"}
   else printf "%16s\t%s\n", $1, "never logged in"}' |sort -k2

Open in new window

0
 

Author Comment

by:cismoney
ID: 36535453
thanx WMP,

the script is  .sh ?
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36535461
It works with sh, ksh and bash
0

Featured Post

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Article by: btan
The intent is not to repeat what many has know about Ransomware but more to join its dots of what is it, who are the victims, why it exists, when and how we respond on infection. Lastly, sum up in a glance to share such information with more to help…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question