Linux / UNIX Tech Support Forum
This is a discussion on Add multiple users to a group within the Linux software forums, part of the Linux Getting Started category; Can someone help me? I want to be able to add multiple users to a group. Is there a script ...
|
|||||||
| Linux software General questions and discussion about Redhat/Fedora Core/Cent OS, Debian and Ubuntu Linux related to softwares should go here. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Can someone help me? I want to be able to add multiple users to a group.
Is there a script that will allow me to do this? The users already exist I would like to add them to a particular group. thanks chuck |
| Sponsored Links | ||
|
|
|
||||
|
Assuming that usernames are in users.txt file
Code:
user1 user2 user3 user4 Code:
#!/bin/bash
INPUT=users.txt
USERS=$(cat $INPUT)
nGROUPS="ftp, sales"
mGROUPS=""
for u in $USERS
do
pGgroups="$(id -Gn ${u} | sed -e 's/ /,/g')"
mGROUPS="${pGgroups},${nGROUPS}"
# old version
usermod -G $mGROUPS $u
# new version group add needs no hack
# usermod -a $nGROUPS $u
done
__________________
Vivek | My personal blog Linux Evangelist + ADD [SOLVED] thread prefix to your thread when your problem is sorted out by editing your thread. + Always use CODE tags for posting system output and commands! |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| set up e-mail group | karpos | Mail Servers | 1 | 06-01-2007 12:28 AM |
| Script to add users to multiple servers. | deepakhg | Shell scripting | 0 | 03-17-2007 03:02 AM |
| Group Policy | bubloob_13 | Windows Xp/2000/2003 server administration | 0 | 01-31-2007 02:31 PM |
| Group Policy | bubloob_13 | Windows Xp/2000/2003 server administration | 1 | 12-20-2006 03:22 PM |
| win2k3 Group policy | bubloob_13 | Windows Xp/2000/2003 server administration | 1 | 12-11-2006 12:30 PM |