Solved

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

Posted on 2011-09-14
3
3,314 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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Fine Tune your automatic Updates for Ubuntu / Debian
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

628 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