Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-14
3
Medium Priority
?
3,485 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 2000 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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

No security measures warrant 100% as a "silver bullet". The truth is we also cannot assume anything but a defensive and vigilance posture. Adopt no trust by default and reveal in assumption. Only assume anonymity or invisibility in the reverse. Safe…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…
Suggested Courses

688 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