LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 08: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, 09: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: 335Reputation: 335Reputation: 335Reputation: 335
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 09:21 AM.
 
Old 01-24-2011, 09: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, 09:26 AM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
something like this mite work:
Code:
for user in `cat users.lst`
do
 sudo useradd -D $user
done
 
Old 01-24-2011, 10: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: 335Reputation: 335Reputation: 335Reputation: 335
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 10:40 AM.
 
Old 01-24-2011, 12:28 PM   #6
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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, 01: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: 335Reputation: 335Reputation: 335Reputation: 335
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, 02:02 PM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

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


Reply



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

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

All times are GMT -5. The time now is 01:46 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
Open Source Consulting | Domain Registration