useradd script

Hallo all

I was trying to make a useradd end userdell script.
Now i found this site
Create Users And Change Passwords With A Bash Script | HowtoForge - Linux Howtos and Tutorials

And i did what the sad and the useradd, userdel and pass scripts work.
Dis is what i have
a list with users saved a userlist.txt

uderadd script:
#!/bin/sh
for i in more userlist.txt
do
echo $i
useradd $i
done

Then i type in the terminal ./useradd.txt
Then the users are added.
then i have a password script:
#!/bin/sh
for i in more userlist.txt
do
echo $i
echo $i"123" | passwd “$i” --stdin
echo; echo “User $username’s password changed!”
done

then the user has his name with 123 as password.
Now in the comment function on the site some one posted a script like this:
#!/bin/sh
for i in more userlist.txt
do
echo $i
echo $i | change -d 0 “$i”
echo; echo “User $i will be forced to change password on next login!”
done

then users had to change there password when the log in the first time.
And i tried that script but then i get this massage:
nurealam
./pass1.txt: line 5: change: command not found

Now my question is what is wrong with that script ?
All other scripts work fine.

Userdel script i have:

#!/bin/sh
for i in more userlist.txt
do
echo $i
userdel -r $i
done

Greet Davano

Hello Davano,

First of all next time you post code/output please put it in code tags.
Posting in Code Tags - A Guide**

**

The command isn’t change but chage.
More information about the chage command here: chage

Good luck!:wink:

Thx for the reply.

And sorry will post it in code tags next time.

I now changed it to chage and now it works.
When i log in with the user i need to change the password.
But it wont log in because there is now home folder.
i get the massage:

Cannot enter home directory. Using /.

When i look in the directory the home folders are not there.

Can the code be changed so that is greats the home folders to ?
If so what do i need to change in the code ?

Greet Davano

Pass the -m option to the useradd command


#!/bin/sh
for i in `more userlist.txt `
do
   echo $i
   useradd -m $i
done

For more information about the useradd command type


man useradd

Good luck,
Hiatt

Thx for the reply.

Dint no i can just add the useradd options.
I already played with the options in the terminal.
So then i will go and play around with the useradd options in the script.

Again thanks all for the help.

Greets Davano