users - groups - profiles

Gavin McCullagh gmccullagh at gmail.com
Mon Dec 17 20:08:12 GMT 2007


Hi,

On Mon, 17 Dec 2007, antonello facchetti wrote:

> But now I'm looking for a way to put things in order in the existing 
> system, i.e. grant cd floppy and audio access to all the users. 
> Obviously I'm looking for an "elegant" solution, I don't want to change 
> permissions to all users one by one.

You could think about changing the group associated with those devices, but
that's probably not a smart plan as you'll confuse other things later.

A little shell scripting should be enough.  I'm going to presume you want
all regular users added to some group.  Firstly, to make a list of all
users, we should be able to do:

	awk -F: '{ if($3 > 999 && $3 < 2000) { print $1} }' /etc/passwd

which lists off all of the users with UserID between 1000 and 2000.  So, to
add them all to some group do this:

for i in `awk -F: '{ if($3 > 999 && $3 < 2000) { print $1} }' /etc/passwd`
do
	echo sudo adduser $i cdrom
done

which should loop over all of the users, printing out the command it would
run for each one,  Take a look at the output and then run if you're happy
with what it does, run it without the echo:

for i in `awk -F: '{ if($3 > 999 && $3 < 2000) { print $1} }' /etc/passwd`
do
	sudo adduser $i cdrom
done

which will loop over all the users adding them to the group cdrom.  You can
then do the same for the other groups you want.

It should prompt you for your password the first time.

> BTW it would be nice if I could define which profile to use in webmin
> batch process, but I don't know how, yet.

Sorry, I don't really know much about webmin :-(

Gavin




More information about the edubuntu-users mailing list