|
Light Poster
|
|
| 2Jul2007,11:43 | #11 |
|
btw wats the command to run the script?
|
|
Go4Expert Member
|
|
| 2Jul2007,12:31 | #12 |
|
To run the script you would use:
Code:
bash <scriptname>.sh |
|
Go4Expert Member
|
|
| 2Jul2007,13:17 | #13 |
|
I will go through some parts of your code with you, though I know that you have not run this code because it will not do anything productive:
Code:
sux – #input command line sux – to enter root
echo“123pass” #input password 123pass
Code:
groupadd –g 747 IMFDelegates #create group with command line groupadd –g 747 IMFDelegates Code:
useradd -c common-name -d /home/username -g gid -u uid -s shell -p password Code:
while [ $num –lt 99]
do
echo user:x:$uid:747:Secret Agent${num}:/home/agent:/bin/sh #create account
num=$((num+1))
passwd user${num} #create password
echo “p@Ss${num}”
done
Basically I hope you are just having a hard time digesting the way scripting works because it doesn't look like you've put too much effort into making this script work. Again I have to ask if you've even tried to run it? Against my better judgement, here is the script I wrote. I just hope that when you take this into class and they ask you what each part is doing, you can explain it: Code:
#!/bin/bash
path="/usr/sbin/"
uid=1900;
${path}groupadd -g 747 IMFDelegates
while [ ${uid} -lt 2000 ]; do
${path}useradd -c "Secret Agent $(($uid-1900))" -d /home/agent$(($uid-1900)) -g 747 -u ${uid} -s /bin/sh -p p@sS$(($uid-1900)) user$(($uid-1900))
let uid=uid+1
done
|
|
Light Poster
|
|
| 4Jul2007,12:15 | #14 |
|
Yes i managed to run successfully! Thank you very much on your source code i get the group, user id and user name correct the only problem i face is the password whe i keyed in correctly it says login failed. Do i have to make changes in the shadow file for it to recognise the password?
anyway i was tasked to create a script to delete the useracct and groups here is my code Code:
#!/bin/bash
path="/usr/sbin/"
uid=1900;
while [ ${uid} -lt 2000 ];
do
${path}userdel -p "Secret Agent $(($uid-1900))" -d /home/agent$(($uid-1900)) -g 747 -u ${uid} -s /bin/sh -p user$(($uid-1900))
let uid=uid+1
done
${path}groupdel -p 747 IMFDelegates
|
|
Go4Expert Member
|
|
| 4Jul2007,20:24 | #15 |
|
Again, look at the documentation for these commands.
man userdel or userdel --help man groupdel or groupdel --help Your answer is there. |
