valis

Untitled

Apr 17th, 2011
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.48 KB | None | 0 0
  1. #All the script does is create the new specified group, cuts out all the names from /etc/group #and replaces all commas with a single space. It then places each name into it's own element #inside of an array called 'users'. It then goes through each element of the users array and #adds it to the group. To execute the command, type: ./nameofscript groupname
  2.  
  3. users=( $(cat /etc/group | cut -d: -f4 | tr ',' ' '))
  4.  
  5. groupadd $1
  6.  
  7. for i in ${users[@]}; do
  8.  
  9. usermod -a -G $1 $i
  10.  
  11. done
Advertisement
Add Comment
Please, Sign In to add comment