Multiple User Creation using Shell Script

  1. vi user.txt

u1

u2

u3

u4

u5

u6

u7

u8

u9

u10

u11

u12

u13

u14

u15

Above 15 users been saved to text file user.txt

  1. Creating Script adduser with below lines

for i in `cat user.txt`

do

useradd -c $i -d /home/exam/$i -g users $i

done

  1. Changing permission

for i in `cat examusers-400-600`

do

echo "chmod 000 /home/exam/$i"

chmod 000 /home/exam/$i

#chmod 700 /home/exam/$i

done

  1. Giving Permission

x=1


while [ $x -le 600 ]

do

echo /home/exam/u$x

chmod 755 /home/exam/u$x

let x=$x+1

done


Deleting files and folder :

x=1

while [ $x -le 600 ]

do

echo /home/exam/u$x

rm -rf /home/exam/u$x/*

let x=$x+1

done