- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- adding 500 users
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2005 04:12 PM
тАО11-23-2005 04:12 PM
I have a requirement in adding 500 users in a linux systems ...Is there any easy way that I can do it instead of doing manullay
Thanks
Binu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2005 05:11 PM
тАО11-23-2005 05:11 PM
Re: adding 500 users
if the user names are some sort of continuous like (user1, user2 etc) then you should be able to do it with simple scripting.
otherwise also, if you have list of usernames in a text file then you could use following script:
## script assumes you have one username in a line, the file name is assumed to be user-list
## It adds the users using useradd command, creates the home directory (as per username)
## sets the group id as 100 (users group), sets the login shell as /bin/bash
## after creation sets the password as same as username.
#!/bin/bash
while read userid
do
echo "Creating useraccount $userid"
useradd -m -g 100 -s /bin/bash $userid
if [ $? == 0 ]; then
echo "created successfully"
else
echo "failed to create user account $userid"
exit
fi
echo $userid | passwd --stdin $userid
done < user-list
Hope this helps,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2005 05:23 PM
тАО11-23-2005 05:23 PM
Re: adding 500 users
do this in script:
#!/bin/bash
i=1000
while test $i -lt 1500
do
/usr/sbin/useradd -u $i -g group -d /home/user$i -s /bin/bash -m user$i
done
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2005 06:13 PM
тАО11-23-2005 06:13 PM
Re: adding 500 users
index=1
while [[ ${index} -lt 501 ]]
do
/usr/sbin/useradd
let index=index+1
done
Post your requirement of user details as,
user Id from to.
group name / group ID
home directory
etc.
details to give exact script.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2005 07:18 PM
тАО11-23-2005 07:18 PM
Re: adding 500 users
I want the user to be like user1 to user500 no need of taking from user-list
where shall i mention that
Thanks
Binu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2005 07:31 PM
тАО11-23-2005 07:31 PM
Solutionchange the username however you want(next to do statement)
#!/bin/bash
let i=1
while [ $i -le 500 ]
do
userid="user"$i
let i=$i+1
echo "Creating useraccount $userid"
useradd -m -g 100 -s /bin/bash $userid
if [ $? == 0 ]; then
echo "created successfully"
else
echo "failed to create user account $userid"
exit
fi
echo $userid | passwd --stdin $userid
done
Hope this helps,
Gopi