User Tools

Site Tools


shell_tips:adding_multiple_users

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
shell_tips:adding_multiple_users [2012/08/14 12:36]
ikahugu
shell_tips:adding_multiple_users [2012/08/14 12:43] (current)
ikahugu
Line 23: Line 23:
 5. With random passwords 5. With random passwords
 <code> <code>
-$for usernum in {1..50}; do  useradd -m user$usernum;  echo `</dev/urandom tr -dc a-z | head -c 10`|passwd --stdin user$usernum ; gpasswd -a "user$usernum" sshd; /bin/cp -f  /home/user/.bashrc /home/"user$usernum";done+$for usernum in {1..50}; do  useradd -m user$usernum;   
 +echo `</dev/urandom tr -dc a-z | head -c 10`|passwd --stdin user$usernum ;  
 +gpasswd -a "user$usernum" sshd;  
 +/bin/cp -f  /home/user/.bashrc /home/"user$usernum";done
 </code> </code>
  
 **Note**: We have used /bin/cp to escape cp alias in bash; this is usually on Centos **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 
 +
 +<code>
 +for usernum in {1..50}; do  userdel -r -f user$usernum; done
 +</code>
shell_tips/adding_multiple_users.1344947817.txt.gz · Last modified: 2012/08/14 12:36 by ikahugu