LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to add new user via shell script (http://www.linuxquestions.org/questions/linux-software-2/how-to-add-new-user-via-shell-script-618765/)

Ingenico1 02-05-2008 01:44 AM

How to add new user via shell script
 
Hi !

I have to add new user with password using shell script(using only adduser command not useradd), I need to read user name & password from the file.

Thanks for help.

Zmyrgel 02-05-2008 01:59 AM

I think the adduser is already a script which uses the useradd command.

I think it quite hard to write a script to use the adduser and not the useradd.

I think python would be nice for this kind of work.
Read a line from file, check the line for errors, use system command IIRC to use the useradd to add the user, read next line of file ...

Ingenico1 02-06-2008 02:41 AM

Hi

I use, reading password from the file AddPassword

adduser -g GroupName -h /home/Marad100 Marad100 < /AddPassword

However adding password had been failed.

I got
Changing password for Marad100
Enter the new password (minimum of 5, maximum of 8 characters)
Please use a combination of upper and lower case letters and numbers.
Enter new password:
Re-enter new password:
passwd: The password for Marad100 is unchanged.

How can i add password using adduser ?

Thanks

izzy8x 10-05-2008 03:14 PM

Hey
 
Have you tried passwd username ?? It basically prompts you for a new password for the given username without requesting the old one. If the command is written alone will understand you wish to change the username's password pointing in the current shell session.

I should add is a separate command though.


All times are GMT -5. The time now is 10:53 PM.