script to change primary group.
Hey,
I need an script to change primary group. Got a linuxbox running ldap + samba. Do anybody got any tips on why I can make this script? It is about 400 user. please help |
unrelated to networking. Moved to Linux - Newbie.
|
I assume that you have a list of users called users_list. You may get a copy of /etc/passwd and manipulate it with sed or awk to compile the list.
Quote:
|
Quote:
The problem is that i have 400 user who should have different primarygroup. I got alle the usernames + password etc in an excel file. |
A little more information:
The users downunder her, I want their primarygroup to be "tbu" username ou=Teachers,ou=Users,dc=skole,dc=lk,dc=local uid l513 ou=Teachers,ou=Users,dc=skole,dc=lk,dc=local uid l514 ou=Teachers,ou=Users,dc=skole,dc=lk,dc=local uid l516 ou=Teachers,ou=Users,dc=skole,dc=lk,dc=local uid l518 But i want these users to have primary group "tau" LXXX = username ou=Teachers,ou=Users,dc=skole,dc=lk,dc=local uid l320 ou=Teachers,ou=Users,dc=skole,dc=lk,dc=local uid l321 ou=Teachers,ou=Users,dc=skole,dc=lk,dc=local uid l324 ou=Teachers,ou=Users,dc=skole,dc=lk,dc=local uid l326 ou=Teachers,ou=Users,dc=skole,dc=lk,dc=local uid l327 ou=Teachers,ou=Users,dc=skole,dc=lk,dc=local uid l328 ou=Teachers,ou=Users,dc=skole,dc=lk,dc=local uid l329 ou=Teachers,ou=Users,dc=skole,dc=lk,dc=local uid l330 ou=Teachers,ou=Users,dc=skole,dc=lk,dc=local uid l333 |
Excel Menu
File >> Save as >> Save as type (Choose txt) |
Quote:
.bat script? |
make file with vi editor named /solution.sh as ChrisAbela said and write following codes on
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #!/bin/sh for i in `cat users_list` do usermod -g new_initial_group $i ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make file with vi editor named /users_list and write following (add ur usernames ) : nancy mohammad naser fredrick ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #./solution.sh |
Quote:
root@ma01:~# /etc/script/set_primary_group.sh -bash: /etc/script/set_primary_group.sh: Permission denied Got tips for that to ? :P |
Why are you putting scripts in /etc?? Very bad place for them.
mv /etc/script/set_primary_group.sh /root/ chmod +x /root/set_primary_group.sh /root/set_primary_group.sh |
ye, i figured out.
its working perfectly. thanks. |
All times are GMT -5. The time now is 05:20 AM. |