1834144 Members
2054 Online
110064 Solutions
New Discussion

User Deletion script

 
SOLVED
Go to solution
Oktay Tasdemir
Advisor

User Deletion script

Hi,

I am running HP-UX 11 and in need of a user deletion script to systematically cleanse the /etc/passwd as there are over 300 entries in there, SAM is too slow.

Many thanks
Let the fun and games begin
3 REPLIES 3
Patrick Wallek
Honored Contributor
Solution

Re: User Deletion script

Have a look at the userdel command. YOu could script it fairly easily.

'man userdel' for more information.
John Poff
Honored Contributor

Re: User Deletion script

Hi,

Have you taken a look at the 'userdel' command? It should do the trick for you. Just make a list of the user accounts you want to delete from /etc/passwd and then write a little script to pass them to userdel. If you make a list of account names to delete and put them in a file named users.del, you could do a little script like this:

while read DEL
do
userdel -r $DEL
done

JP
V. V. Ravi Kumar_1
Respected Contributor

Re: User Deletion script

hi,
u can do this with userdel command. get all usernames into a file. Edit the file and delete the user names those u don't want to remove. Ex: root, lp, sys, bin etc.,

#cat /etc/passwd|cut -f 1 -d: >/tmp/passwd

for i in `cat /tmp/passwd`
do
userdel -r $i
done

Regards
Never Say No