Script for deleting orphan ids & unknown gecos

The AIX servers that I am working on have been identified as having orphaned user ids & improper gecos for some user ids. Can someone help me with a script to delete the user ids if the orphaned ids are provided in a text file. The home directory set up for the user ids happen to be the application folder and hence that should not be deleted.

G

You probably want to do something like this:

First, add a soft link from /bin/false to /usr/bin/nologin

Next, have a list of user-names in a text file, one name per line. Then prepare the following script:

!/bin/sh
cat your-text-file-of-usernames |
while read uname ; do
   if chsh "$uname" /usr/bin/nologin ; then
     echo Logins blocked to "$uname" 
   else
     echo An error occurred attempting to block login to "$uname"
   fi
done

Now, it's possible that you will have to add the nologin pseudo-shell to the list of shells that are valid. If it fails for every user, then you'll need to figure out how to add it to the list. The AIX manual says:

You can also instead do this, a very AIX-specific method:

cat your-text-file-of-usernames |
while read uname ; do
   if chuser account_locked=true "$uname" ; then
     echo Account locked for "$uname" 
   else
     echo An error occurred attempting to lock login to "$uname"
   fi
done

Note, I have not tested this as I don't have access to an AIX host.