shell_tips:adding_multiple_users
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
shell_tips:adding_multiple_users [2012/08/14 12:31] – created ikahugu | shell_tips:adding_multiple_users [2012/08/14 12:43] (current) – ikahugu | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | 1. Example of how to add 50 users | + | 1. Example of how to add 50 users without password |
< | < | ||
- | for usernum in {1..50}; do useradd -m user$usernum; | + | $for usernum in {1..50}; do useradd -m user$usernum; |
</ | </ | ||
- | This will create 50 users without password | ||
2. You can generate passwords from the usernames | 2. You can generate passwords from the usernames | ||
< | < | ||
- | for usernum in {1..50}; do useradd -m user$i; echo " | + | $for usernum in {1..50}; do useradd -m user$i; echo " |
</ | </ | ||
Line 14: | Line 13: | ||
< | < | ||
- | for usernum in {1..50}; do echo `</ | + | $for usernum in {1..50}; do echo `</ |
</ | </ | ||
Line 20: | Line 19: | ||
< | < | ||
- | for usernum in {1..50}; do useradd -m user$usernum; | + | $for usernum in {1..50}; do useradd -m user$usernum; |
+ | </ | ||
+ | 5. With random passwords | ||
+ | < | ||
+ | $for usernum in {1..50}; do useradd -m user$usernum; | ||
+ | echo `</ | ||
+ | gpasswd -a " | ||
+ | /bin/cp -f / | ||
+ | </ | ||
+ | |||
+ | **Note**: We have used /bin/cp to escape cp alias in bash; this is usually on Centos | ||
+ | |||
+ | **Delete users** | ||
+ | |||
+ | Remove the above users; including mailboxes and home folders | ||
+ | |||
+ | < | ||
+ | for usernum in {1..50}; do userdel -r -f user$usernum; done | ||
</ | </ |
shell_tips/adding_multiple_users.1344947503.txt.gz · Last modified: 2012/08/14 12:31 by ikahugu