Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how delete 600 user fastest way possible

Status
Not open for further replies.

yordangs

ISP
Sep 7, 2001
91
MX
hello how i can delete 600 users

my user are created like this
aa100001
aa100002
.
.
.
.
.
aa100600

how can delete all this users there is a command that could erase all the users of one erase.

thanks a lot
 
Your best bet is to edit [tt]/etc/passwd[/tt], [tt]/etc/security/passwd[/tt], [tt]/etc/group[/tt], [tt]/etc/security/group[/tt], [tt]/etc/security/passwd[/tt], [tt]/etc/security/user[/tt], [tt]/etc/security/limit[/tt] and then do a [tt]mkpasswd -c[/tt].

Safer bet is to
[tt]
rm -f /etc/passwd.nm.idx /etc/passwd.id.idx /etc/security/passwd.idx /etc/security/lastlog.idx

typeset -iZ3 n=001
while [ $n -le 600 ]
do
rmuser -p aa100$n
let "n=n+1"
done
mkpasswd -vf
[/tt]

I hope it works...
Unix was made by and for smart people.
 
Here is one possible solution:

#!/bin/ksh
a="aa100"
x=0
max=600
while [ "$x" -le "$max" ] ; do
x=`expr $x + 1`
y="000000$x"
z=`echo "$y" |wc -c |awk {'print $1'}`
z=`expr $z - 1`
p=`echo "$y"|cut -c $z`
z=`expr $z - 1`
o=`echo "$y"|cut -c $z`
z=`expr $z - 1`
i=`echo "$y"|cut -c $z`
l="$i$o$p"
m="$a$l"
rmuser -p $m
done
 
ok with this two examples i make this tow scripts

script one

awk '/[a-z]{2}[0-9]{6}/' /etc/passwd > usu
awk -f printUser.awk usu > usuarios
rm usu

when i run this program i have all the user in a file call it usuarios then i run thiis other script and this erase all the user

script two

/home/root/usuarios.sh

for i in `cat usuarios`
do
rmuser -p "$i"
done

and with this i delete all the user


thaks for the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top