[K12OSN] deleting a 1000 users

jam at mcquil.com jam at mcquil.com
Wed Jun 9 15:56:37 UTC 2004

On Wed, 9 Jun 2004, Glenn Arnold wrote:

> I set up a 1000 users with webmin with the batch process.  Now I am
> trying to delete the accounts and for some reason webmin would only
> delete 100 of the accounts the reset it would say that user does not
> exist.  I have seen posted on this group on how to automate user
> deletion using userdel, but when I try it I get the following usage
> error "usage: userdel [-r] name".  Below is what I get when I try this.
> The users I want to delete is in delstu6.txt file.   What am I doing
> wrong with this script?
> Thanks
> -Glenn
>  [root at server garnold]# for x in 'cat delstu6.txt'
> > do userdel -r $x
> > done
> usage: userdel [-r] name

With 1000 names in the delstu6.txt file, you may be having a problem
with the command line being too long.

the  "for x in 'cat delstu6.txt'" gets transformed into:

   for x in  billy bobby susan fred george ... ... ... ... (1000 names )

and that is gonna result in a very long command line.  I know older 
shells like sh and ksh had limitations on command line length. I don't
know about bash though.  It may actually not be a problem.

But, another way to do it would be:

   cat delstu6.txt | while read x
     userdel -r $x

Jim McQuillan
jam at Ltsp.org

> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>

More information about the K12OSN mailing list