Solved

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

Posted on 2011-09-14
3
3,230 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSH setup on ASA 5505 17 116
SMTP log file for IMSVA 5 68
user defined, environmental. local, global variables 4 22
how to write and save a unix script 12 31
Fine Tune your automatic Updates for Ubuntu / Debian
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

737 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