LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-24-2011, 09:52 AM   #1
aggrishabh
Member
 
Registered: Nov 2010
Posts: 87

Rep: Reputation: 1
create 100 users in one go


Hi,

i have a situation,

i have to create 100 users in Linux with some password
can it be done in one go i tried newuser command but the home directory is not created for those users.

plus when i login for the first time into a server i got
EXECUTING /etc/profile ...
EXECUTING .profile ...
EXECUTING /xyz/abc/bin/setenv.ksh file ...

before the prompt. The above three lines shows that some kind of script was set to run when a user login for the first time that will create the home directory (if i am not guessing wrong)and never run if user login again.

how to do that any help appreciated.
 
Old 01-24-2011, 10:15 AM   #2
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Quote:
Originally Posted by aggrishabh View Post
i have to create 100 users in Linux with some password
can it be done in one go i tried newuser command but the home directory is not created for those users.
You can find the answers on these pages.
http://www.linuxheadquarters.com/how.../adduser.shtml
http://linux.about.com/od/commands/l...l8_useradd.htm
Note that the second reference is for the useradd utility which is equivalent to newuser.

The -m option will create the home directory of the new user when used in either newuser or useradd.
The -D option will show you the default behavior of the newuser and the useradd utilities. You can also set the defaults using -D.

Quote:
Originally Posted by aggrishabh View Post
plus when i login for the first time into a server i got
EXECUTING /etc/profile ...
EXECUTING .profile ...
EXECUTING /xyz/abc/bin/setenv.ksh file ...

before the prompt. The above three lines shows that some kind of script was set to run when a user login for the first time that will create the home directory (if i am not guessing wrong)and never run if user login again.
I don't know why you saw those messages. In the first two lines the login process was running normal login scripts. Evidently someone put those messages in those files. Also I suspect that in the third line the /xyz/abc was actually /usr/local which you could have included without any concern about security. In any case it appears to be something that someone else has set up for user login to set environment variables for the Korn shell. Those files are not intended to create the user's home directory. They are intended to create an environment for the user's process.

You should always include information about which Linux distribution you are using, including the version of that distribution, when you ask a question.

Last edited by stress_junkie; 01-24-2011 at 10:21 AM.
 
Old 01-24-2011, 10:21 AM   #3
PhoenixzeroX
LQ Newbie
 
Registered: Jul 2009
Posts: 7

Rep: Reputation: 0
Hi aggrishabh

Maybe this script can help you:

http://www.cyberciti.biz/tips/howto-...-add-user.html

Best regards

PhoenixzeroX
 
Old 01-24-2011, 10:26 AM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,165

Rep: Reputation: 889Reputation: 889Reputation: 889Reputation: 889Reputation: 889Reputation: 889Reputation: 889
something like this mite work:
Code:
for user in `cat users.lst`
do
 sudo useradd -D $user
done
 
Old 01-24-2011, 11:30 AM   #5
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Quote:
Originally Posted by schneidz View Post
something like this mite work:
Code:
for user in `cat users.lst`
do
 sudo useradd -D $user
done
Not -D

That shows/sets defaults.

Speaking of which, the first thing I would do is to set the default of newuser to create the user account home directory without having to have that in the command parameters every time.
Code:
newuser -D -m
That would set the default behavior of newuser to create the new users' home directories without specifying that in each invocation of newuser.

Next, since we don't know the Linux distribution there is no reason to think that the original poster needs to use sudo. Evidently the original poster is able to create new users so he/she already knows about that or, more likely, is using the root account. Since this is in a business it is likely that they are using Red Hat or some more business oriented distribution where use of the root account is expected.

The original poster should tell us the Linux distribution asap since that will affect the details of the solution.

Last edited by stress_junkie; 01-24-2011 at 11:40 AM.
 
Old 01-24-2011, 01:28 PM   #6
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,165

Rep: Reputation: 889Reputation: 889Reputation: 889Reputation: 889Reputation: 889Reputation: 889Reputation: 889
fyi:
Code:
[root@hyper ~]# uname -a -m -p
Linux hyper 2.6.34.7-66.fc13.x86_64 #1 SMP Wed Dec 15 07:04:30 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux
[root@hyper ~]# which newuser
/usr/bin/which: no newuser in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
are you sure you dont mean useradd ?
 
Old 01-24-2011, 02:51 PM   #7
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Quote:
Originally Posted by schneidz View Post
are you sure you dont mean useradd ?
Some distributions have newuser, some have useradd, some have both.
 
Old 01-24-2011, 03:02 PM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,900

Rep: Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611
I guess previous posters mean the newusers command.
 
  


Reply


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
[SOLVED] How to create SSH users rjo98 Linux - Newbie 5 06-10-2010 03:29 PM
Create new users finditsol Puppy 4 04-14-2010 07:27 AM
system requirements for samba server for 100 users boToo Linux - Server 6 12-02-2006 07:17 PM
creating a file server with about 100 users thefallenone Linux - Networking 4 03-14-2005 10:57 PM
Can't create users! Zeke55 Linux - Newbie 9 12-08-2004 02:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:52 PM.

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