Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 02-05-2008, 02:44 AM   #1
LQ Newbie
Registered: Feb 2008
Posts: 2

Rep: Reputation: 0
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.
Old 02-05-2008, 02:59 AM   #2
Senior Member
Registered: Dec 2005
Location: Finland
Distribution: Slackware, CentOS, RHEL, OpenBSD
Posts: 1,006

Rep: Reputation: 37
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 ...
Old 02-06-2008, 03:41 AM   #3
LQ Newbie
Registered: Feb 2008
Posts: 2

Original Poster
Rep: Reputation: 0

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 ?

Old 10-05-2008, 04:14 PM   #4
LQ Newbie
Registered: Oct 2008
Posts: 1

Rep: Reputation: 0
Lightbulb 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.


password, user

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
samba - add user script - User account does not exist itzamecwp Linux - Server 2 01-18-2007 11:52 PM
how to add user in command shell man_J Linux - Software 4 11-05-2006 09:09 AM
Add user to Webmin through SHELL? mikeshn Linux - General 1 12-05-2003 03:00 PM
Add a user thorugh SHELL? mikeshn Linux - General 4 01-08-2003 11:31 PM
Add User Shell Script DAC Programming 2 10-13-2002 04:12 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:46 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration