Operating System - HP-UX
1834047 Members
2803 Online
110063 Solutions
New Discussion

Re: Mass Deletion of Users

 
SOLVED
Go to solution
John_44
Advisor

Mass Deletion of Users

Hello Everyone,

I have about 50 users I have to delete. Each entry in the passwd file is marked with "disabled". Is there an easy way to do this? Or do I have to do userdel -r for each entry?

Any help would be appreciated. Thanks in advance.

John
3 REPLIES 3
Vincenzo Restuccia
Honored Contributor

Re: Mass Deletion of Users

James R. Ferguson
Acclaimed Contributor
Solution

Re: Mass Deletion of Users

Hi John:

You could easily build a temporary script to verify the list your going to delete. For example, if the fifth field (the identification one) of /etc/passwd contained "Disabled", then:

# awk -F: '$5~/Disabled/ {print "userdel -r " $1}' /etc/passwd > /tmp/deleteusers

would create the file of user delete statements for you to review, edit, and or process.

...JRF...
Pedro Sousa
Honored Contributor

Re: Mass Deletion of Users

Hi John!
try the following:
grep -i disable /etc/passwd|cut -d ":" -f1 > /tmp/disable_users| while read USER; do
userdel -r $USER; done < /tmp/disabe_users

good luck.