Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
06-11-2007, 04:32 AM
|
#1
|
LQ Newbie
Registered: Jun 2007
Posts: 4
Rep:
|
Automate user account creation
i have being task to create 100 users... i am able to create the user login name.. but now i have to create the password for these accounts... the solution i found on this forums does not seems to solve my problem... could some one help me??
my script is
Code:
for((i=0; i<=100; i++))
do
useradd -m user$i -u 180$i -g Admin -d /home/user$i -s /bin/sh -c 'User'$i
done
|
|
|
06-11-2007, 04:39 AM
|
#2
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
you can use chpasswd to change passwords in bulk.
|
|
|
06-11-2007, 09:44 AM
|
#3
|
LQ Newbie
Registered: Jun 2007
Posts: 4
Original Poster
Rep:
|
sorry can i ask how do i use this command inside the script???
i want the whole process to be fully automated.. the user should not be ask to enter anything...
thanks in advance...
Last edited by bczm8703; 06-11-2007 at 09:48 AM.
|
|
|
06-11-2007, 09:47 AM
|
#4
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
well you'd just insert it after the useradd command.
|
|
|
06-11-2007, 09:53 AM
|
#5
|
LQ Newbie
Registered: Jun 2007
Posts: 4
Original Poster
Rep:
|
sorry i think my question is not clear or there is a misunderstanding...
can i know the command structure??? cos by putting chpasswd still require the user to input the username and password... what i need is that the user or administrator do not need to enter anything.. he only need to run the script....
|
|
|
06-11-2007, 10:38 AM
|
#6
|
Member
Registered: Jun 2007
Location: Munich, Germany
Distribution: RHEL, CentOS, Fedora, SLES (...)
Posts: 399
Rep:
|
In [1] you can read how pipes can be used efficiently. Then this should be easy:
Code:
echo username:password |chpasswd
You can also pipe a list of login data. Each line should include a username and password seperated by a colon.
[1] http://www.tdl.com/~netex/linux-doc-...e/node122.html
|
|
|
06-12-2007, 09:20 PM
|
#7
|
LQ Newbie
Registered: Jun 2007
Posts: 4
Original Poster
Rep:
|
just to confirm.. the full code will be as follow
Code:
for((i=0; i<=100; i++))
do
useradd -m user$i -u 180$i -g Admin -d /home/user$i -s /bin/sh -c 'User'$i
echo user$i:pass$i |chpasswd
done
|
|
|
All times are GMT -5. The time now is 05:21 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|