I need to add 500+ user to a group. Does anyone know how I can this without adding each person individually? As I think I might be sat in this seat for the next two weeks adding everyone and miss my holiday to Ibiza! Cheers -- Andrew Nix St Pauls Catholic High School Firbank Road Newall Green Wythenshawe Manchester M23 2YS tel: 0161 4375841 ext 168 fax: 0161 4982030
--- Andrew Nix
without adding each person individually? As I think I might be sat in this seat for the next two weeks adding everyone and miss my holiday to Ibiza! Cheers
You can do something like this: for i in $(cat /etc/passwd | awk -F: '{print $1}'); do chown $i.GROUPNAME; done Where-by you replace "GROUPNAME" with the gropname you need. HTH, -- Thomas Adam ===== Thomas Adam "The Linux Weekend Mechanic" -- www.linuxgazette.com ________________________________________________________________________ Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/
--- Thomas Adam
need to add 500+ user to a group. Does anyone know how I can this
without adding each person individually? As I think I might be sat in this seat for the next two weeks adding everyone and miss my holiday to Ibiza! Cheers
You can do something like this:
for i in $(cat /etc/passwd | awk -F: '{print $1}'); do chown $i.GROUPNAME; done
Actually, you don't do that! It won't work.... for i in $(cat /etc/passwd | awk -F: '{print $1}'); do adduser $i GROUPNAME; done The above will work!!! Sorry, Andrew, -- Thomas Adam ===== Thomas Adam "The Linux Weekend Mechanic" -- www.linuxgazette.com ________________________________________________________________________ Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/
--- Thomas Adam
wrote: > --- Andrew Nix wrote: > I need to add 500+ user to a group. Does anyone know how I can this
without adding each person individually? As I think I might be sat in this seat for the next two weeks adding everyone and miss my holiday to Ibiza! Cheers
You can do something like this:
for i in $(cat /etc/passwd | awk -F: '{print $1}'); do chown $i.GROUPNAME; done
Actually, you don't do that! It won't work....
for i in $(cat /etc/passwd | awk -F: '{print $1}'); do adduser $i GROUPNAME; done
Will that add everyone in /etc/passwd? If so there are profiles in there that dont need to be added to the group. I should have said this earlier. I have a spreadsheet that was used to create all the profile and I want. I used a commmand something like: addnewuser <filename of spreadsheet> and it created them all for me! Can something similar be done with groups?
The above will work!!!
Sorry, Andrew,
-- Thomas Adam
===== Thomas Adam
"The Linux Weekend Mechanic" -- www.linuxgazette.com
________________________________________________________________________ Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
--- Andrew Nix
wrote: > I need to add 500+ user to a group. Does anyone know how I can this
without adding each person individually? As I think I might be sat in this seat for the next two weeks adding everyone and miss my holiday to Ibiza! Cheers
You can do something like this:
for i in $(cat /etc/passwd | awk -F: '{print $1}'); do chown $i.GROUPNAME; done
Actually, you don't do that! It won't work....
for i in $(cat /etc/passwd | awk -F: '{print $1}'); do adduser $i GROUPNAME; done
Will that add everyone in /etc/passwd? If so there are profiles in there that dont need to be added to the group. I should have said this earlier.
I am fully aware of that, and it was a very quick hack.
I have a spreadsheet that was used to create all the profile and I want. I used a commmand something like:
addnewuser <filename of spreadsheet>
and it created them all for me! Can something similar be done with groups?
Assuming that you have the list of users, export it to a cvs (a comma separated file) and issue the command: for i in $(cat ./the_file | awk -F, '{print $NUM}'); do useradd $NUM -G groupname; done You'll have to change the above so that $NUM is the column number that the username appears in (i.e. $1, $2, etc) and change "groupname" as appropriate. HTH, -- Thomas Adam
The above will work!!!
Sorry, Andrew,
-- Thomas Adam
===== Thomas Adam
"The Linux Weekend Mechanic" -- www.linuxgazette.com
________________________________________________________________________
Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
===== Thomas Adam "The Linux Weekend Mechanic" -- www.linuxgazette.com ________________________________________________________________________ Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/
This is the command you said would work if i had a cvs file?
for i in $(cat ./the_file | awk -F, '{print $NUM}'); do useradd $NUM -G groupname; done
As it was just easier to copy all the usernames into a text file will the this same command work? If so what do I write for $NUM, as there are no columns to be defined? Is there an addgroup cammand that could also do the same thing or am I barking up the wrong tree? -- Andrew Nix St Pauls Catholic High School Firbank Road Newall Green Wythenshawe Manchester M23 2YS tel: 0161 4375841 ext 168 fax: 0161 4982030
--- Andrew Nix
This is the command you said would work if i had a cvs file?
for i in $(cat ./the_file | awk -F, '{print $NUM}'); do useradd $NUM -G groupname; done
Hmm, It seems I am having a lapse in my typing. Once and for all, the
_correct_ way is to do:
for i in $(cat ./the_file); do useradd $i -G <groupname>,
As it was just easier to copy all the usernames into a text file will the this same command work? If so what do I write for $NUM, as there are no columns to be defined? Is there an addgroup cammand that could also do the same thing or am I barking up the wrong tree?
(see above). Since you only have one column, invoking awk in this case is superfluous and unnecessary. You might just was well cat the file. You'll also notice that I have got <groupname> followed by a comma, and then <moregroups>. This is so that you can specify more than one group to add if need be. There is no "addgroup" command, as it is all contained within useradd. In debian, one can do it more simpler, but this is SuSE, so.... HTH, -- Thomas Adam
-- Andrew Nix
St Pauls Catholic High School Firbank Road Newall Green Wythenshawe Manchester M23 2YS tel: 0161 4375841 ext 168 fax: 0161 4982030
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
===== Thomas Adam "The Linux Weekend Mechanic" -- www.linuxgazette.com ________________________________________________________________________ Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/
--- Andrew Nix
wrote: This is the command you said would work if i had a cvs file?
for i in $(cat ./the_file | awk -F, '{print $NUM}'); do useradd $NUM -G groupname; done
I tried this command but i very time I run it, it just says group unknown. This is the exact command I issue: for i in $(cat ./Group\ Adding); do useradd $i -G @Students; done Im in the directory where the list of users is when the command is run. Can anyone see if Im doing something wrong?
Hmm, It seems I am having a lapse in my typing. Once and for all, the _correct_ way is to do:
for i in $(cat ./the_file); do useradd $i -G <groupname>,
; done As it was just easier to copy all the usernames into a text file will the this same command work? If so what do I write for $NUM, as there are no columns to be defined? Is there an addgroup cammand that could also do the same thing or am I barking up the wrong tree?
(see above). Since you only have one column, invoking awk in this case is superfluous and unnecessary. You might just was well cat the file. You'll also notice that I have got <groupname> followed by a comma, and then <moregroups>. This is so that you can specify more than one group to add if need be.
There is no "addgroup" command, as it is all contained within useradd. In debian, one can do it more simpler, but this is SuSE, so....
HTH,
-- Thomas Adam
-- Andrew Nix
St Pauls Catholic High School Firbank Road Newall Green Wythenshawe Manchester M23 2YS tel: 0161 4375841 ext 168 fax: 0161 4982030
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
===== Thomas Adam
"The Linux Weekend Mechanic" -- www.linuxgazette.com
________________________________________________________________________ Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
--- Andrew Nix
wrote: This is the command you said would work if i had a cvs file?
for i in $(cat ./the_file | awk -F, '{print $NUM}'); do useradd $NUM -G groupname; done
I tried this command but i very time I run it, it just says group unknown. This is the exact command I issue:
for i in $(cat ./Group\ Adding); do useradd $i -G @Students; done
Im in the directory where the list of users is when the command is run. Can anyone see if Im doing something wrong?
I appologize for getting the command wrong. I removed the @ before Students. But It tells me the user already exsists and doesnt add them to the group. Does anyone have any idea what im doin wrong?
Hmm, It seems I am having a lapse in my typing. Once and for all, the _correct_ way is to do:
for i in $(cat ./the_file); do useradd $i -G <groupname>,
; done As it was just easier to copy all the usernames into a text file will the this same command work? If so what do I write for $NUM, as there are no columns to be defined? Is there an addgroup cammand that could also do the same thing or am I barking up the wrong tree?
(see above). Since you only have one column, invoking awk in this case is superfluous and unnecessary. You might just was well cat the file. You'll also notice that I have got <groupname> followed by a comma, and then <moregroups>. This is so that you can specify more than one group to add if need be.
There is no "addgroup" command, as it is all contained within useradd. In debian, one can do it more simpler, but this is SuSE, so....
HTH,
-- Thomas Adam
-- Andrew Nix
St Pauls Catholic High School Firbank Road Newall Green Wythenshawe Manchester M23 2YS tel: 0161 4375841 ext 168 fax: 0161 4982030
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
===== Thomas Adam
"The Linux Weekend Mechanic" -- www.linuxgazette.com
________________________________________________________________________ Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
--- Andrew Nix
--- Andrew Nix
wrote: This is the command you said would work if i had a cvs file?
for i in $(cat ./the_file | awk -F, '{print $NUM}'); do useradd $NUM -G groupname; done
I tried this command but i very time I run it, it just says group unknown. This is the exact command I issue:
for i in $(cat ./Group\ Adding); do useradd $i -G @Students; done
Yes, "@students" suggest a perl array, in which case Bash cannot expand it. -- Thomas Adam
Im in the directory where the list of users is when the command is run. Can anyone see if Im doing something wrong?
Hmm, It seems I am having a lapse in my typing. Once and for all, the _correct_ way is to do:
for i in $(cat ./the_file); do useradd $i -G <groupname>,
; done As it was just easier to copy all the usernames into a text file will the this same command work? If so what do I write for $NUM, as there are no columns to be defined? Is there an addgroup cammand that could also do the same thing or am I barking up the wrong tree?
(see above). Since you only have one column, invoking awk in this case is superfluous and unnecessary. You might just was well cat the file. You'll also notice that I have got <groupname> followed by a comma, and then <moregroups>. This is so that you can specify more than one group to add if need be.
There is no "addgroup" command, as it is all contained within useradd. In debian, one can do it more simpler, but this is SuSE, so....
HTH,
-- Thomas Adam
-- Andrew Nix
St Pauls Catholic High School Firbank Road Newall Green Wythenshawe Manchester M23 2YS tel: 0161 4375841 ext 168 fax: 0161 4982030
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
===== Thomas Adam
"The Linux Weekend Mechanic" -- www.linuxgazette.com
________________________________________________________________________
Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
===== Thomas Adam "The Linux Weekend Mechanic" -- www.linuxgazette.com ________________________________________________________________________ Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/
--- Andrew Nix
--- Andrew Nix
wrote: This is the command you said would work if i had a cvs file?
for i in $(cat ./the_file | awk -F, '{print $NUM}'); do useradd $NUM -G groupname; done
I tried this command but i very time I run it, it just says group unknown. This is the exact command I issue:
for i in $(cat ./Group\ Adding); do useradd $i -G @Students; done
Im in the directory where the list of users is when the command is run. Can anyone see if Im doing something wrong?
I appologize for getting the command wrong. I removed the @ before Students. But It tells me the user already exsists and doesnt add them to the group. Does anyone have any idea what im doin wrong?
Yes, I think that I am confusing the issue by a factor of X^Y. Unlike Debian's 'useradd', SuSE doesn't offer the same functionality. Therefore, still using the same command as you have been using, change "useradd" for "usermod" and then try it. -- Thomas Adam
Hmm, It seems I am having a lapse in my typing. Once and for all, the _correct_ way is to do:
for i in $(cat ./the_file); do useradd $i -G <groupname>,
; done As it was just easier to copy all the usernames into a text file will the this same command work? If so what do I write for $NUM, as there are no columns to be defined? Is there an addgroup cammand that could also do the same thing or am I barking up the wrong tree?
(see above). Since you only have one column, invoking awk in this case is superfluous and unnecessary. You might just was well cat the file. You'll also notice that I have got <groupname> followed by a comma, and then <moregroups>. This is so that you can specify more than one group to add if need be.
There is no "addgroup" command, as it is all contained within useradd. In debian, one can do it more simpler, but this is SuSE, so....
HTH,
-- Thomas Adam
-- Andrew Nix
St Pauls Catholic High School Firbank Road Newall Green Wythenshawe Manchester M23 2YS tel: 0161 4375841 ext 168 fax: 0161 4982030
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
===== Thomas Adam
"The Linux Weekend Mechanic" -- www.linuxgazette.com
Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
===== Thomas Adam "The Linux Weekend Mechanic" -- www.linuxgazette.com ________________________________________________________________________ Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/
Yes, I think that I am confusing the issue by a factor of X^Y. Unlike Debian's 'useradd', SuSE doesn't offer the same functionality. Therefore, still using the same command as you have been using, change "useradd" for "usermod" and then try it.
I changed the it to usermod. But I get the reply user Students doesnt exsist. Below is the exact command issued. Is there something wrong with it? Or is theresomething else i need to add to it? for i in $(cat ./KS3_20023_PUPILS.csv | awk -F, '{print $1}'); do usermod $1 -G @Students; done I also tried it with a text file and the command is this: for i in $(cat ./Group\ Adding); do usermod $i -G Students; done But each time I get the same response. Any idea anyone? Cheers -- Andrew Nix St Pauls Catholic High School Firbank Road Newall Green Wythenshawe Manchester M23 2YS tel: 0161 4375841 ext 168 fax: 0161 4982030
On Friday 08 August 2003 09:23, Andrew Nix wrote:
Yes, I think that I am confusing the issue by a factor of X^Y. Unlike Debian's 'useradd', SuSE doesn't offer the same functionality. Therefore, still using the same command as you have been using, change "useradd" for "usermod" and then try it.
I changed the it to usermod. But I get the reply user Students doesnt exsist. Below is the exact command issued. Is there something wrong with it? Or is theresomething else i need to add to it?
for i in $(cat ./KS3_20023_PUPILS.csv | awk -F, '{print $1}'); do usermod $1 -G @Students; done
I also tried it with a text file and the command is this:
for i in $(cat ./Group\ Adding); do usermod $i -G Students; done
I get the same error message with the above code. However, it does work fine on SuSE8.2 if you use useradd instead of usermod :-) for i in $(cat ./newusers); do useradd $i -G students; done Alastair
But each time I get the same response. Any idea anyone? Cheers
-- Andrew Nix
St Pauls Catholic High School Firbank Road Newall Green Wythenshawe Manchester M23 2YS tel: 0161 4375841 ext 168 fax: 0161 4982030
On Friday 08 August 2003 09:23, Andrew Nix wrote:
Yes, I think that I am confusing the issue by a factor of X^Y. Unlike Debian's 'useradd', SuSE doesn't offer the same functionality. Therefore, still using the same command as you have been using, change "useradd" for "usermod" and then try it.
I changed the it to usermod. But I get the reply user Students doesnt exsist. Below is the exact command issued. Is there something wrong with it? Or is theresomething else i need to add to it?
for i in $(cat ./KS3_20023_PUPILS.csv | awk -F, '{print $1}'); do usermod $1 -G @Students; done
I also tried it with a text file and the command is this:
for i in $(cat ./Group\ Adding); do usermod $i -G Students; done
I get the same error message with the above code. However, it does work fine on SuSE8.2 if you use useradd instead of usermod :-)
for i in $(cat ./newusers); do useradd $i -G students; done
I use 8.2 and I agree it would work if the users werent already set up. But as they are it just tells me that they do exsist! Any other ideas?
Alastair
But each time I get the same response. Any idea anyone? Cheers
-- Andrew Nix
St Pauls Catholic High School Firbank Road Newall Green Wythenshawe Manchester M23 2YS tel: 0161 4375841 ext 168 fax: 0161 4982030
-- To unsubscribe, e-mail: suse-linux-uk-schools-unsubscribe@suse.com For additional commands, e-mail: suse-linux-uk-schools-help@suse.com
Hi Andrew Its a syntax problem - usermod requires the login name after the group for i in $(cat ./newusers); do usermod -G students $i; done this works fine Alastair On Friday 08 August 2003 09:57, Andrew Nix wrote:
On Friday 08 August 2003 09:23, Andrew Nix wrote:
Yes, I think that I am confusing the issue by a factor of X^Y.
Unlike Debian's 'useradd', SuSE doesn't offer the same functionality. Therefore, still using the same command as you have been using, change "useradd" for "usermod" and then try it.
I changed the it to usermod. But I get the reply user Students doesnt exsist. Below is the exact command issued. Is there something wrong with it? Or is theresomething else i need to add to it?
for i in $(cat ./KS3_20023_PUPILS.csv | awk -F, '{print $1}'); do usermod $1 -G @Students; done
I also tried it with a text file and the command is this:
for i in $(cat ./Group\ Adding); do usermod $i -G Students; done
I get the same error message with the above code. However, it does work fine on SuSE8.2 if you use useradd instead of usermod :-)
for i in $(cat ./newusers); do useradd $i -G students; done
I use 8.2 and I agree it would work if the users werent already set up. But as they are it just tells me that they do exsist! Any other ideas?
Alastair
But each time I get the same response. Any idea anyone? Cheers
--- Alastair Duncan
Its a syntax problem - usermod requires the login name after the group
for i in $(cat ./newusers); do usermod -G students $i; done
this works fine
This is a classic case of me not reading the man page before pasting the code in, and for not remembering the syntax of the command -- I really do apologise lately for my lack of concentration -- it is unacceptbable. I am assuming from Andrew that the users do actually exist, and thus "usermod" is the correct program to use in this instance. Sorry, -- Thomas Adam ===== Thomas Adam "The Linux Weekend Mechanic" -- www.linuxgazette.com ________________________________________________________________________ Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/
Cheers Alastair. This command worked a treat. I apprcaite everyone help for this long and very dragged out problem. I feel so relived that something finally worked :-)
Hi Andrew
Its a syntax problem - usermod requires the login name after the group
for i in $(cat ./newusers); do usermod -G students $i; done
this works fine
Alastair
participants (3)
-
Alastair Duncan
-
Andrew Nix
-
Thomas Adam