[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Changing groups



On Thu, 2003-08-14 at 17:43, Dan Jones wrote:
> <Quote>
> You are a member of one group at all times. When you log in you are
> placed in your default group, which is set when root creates your user
> account. You can belong to many different groups, but you can be logged
> in to only one group at a time. To change the group you are a member of,
> use the newgrp command. For example, if you are a member of a group
> called users and also a group called programmers, and you need to change
> to the programmers group because they have special access to a compiler,
> issue this command:
> 
> newgrp programmers
> 
> Linux does not tell you which group you’re in. Usually the only way to
> find out which group is active is to save a file and then look at the
> permissions.
> </Quote>

umm, 
mrroach@flmrroach:~$ groups
mrroach lp cdrom floppy audio

> > Why is newgrp there?  Two reasons.  One, to change to a group you
> > aren't defined as a member of, but have the password (who ever
> > thought THAT was a good idea!).  Two, to get a shell in that group
> > without logging everything out.
> 
> Try it yourself.  Create a new group and add yourself to it.  Then
> create a file, change it's owner to whoever and its group to the new
> group.  Set permissions to 770 and try to read the file.
> 
> Then use newgrp to change your group and try to read it.

mrroach@flmrroach:~$ sudo groupadd silly
mrroach@flmrroach:~$ sudo adduser mrroach silly
Adding user mrroach to group silly...
Done.
mrroach@flmrroach:~$ sudo touch /tmp/sillyfile
mrroach@flmrroach:~$ sudo chown root:silly /tmp/sillyfile
mrroach@flmrroach:~$ sudo chmod 770 /tmp/sillyfile
mrroach@flmrroach:~$ sudo su mrroach
mrroach@flmrroach:~$ groups
mrroach lp cdrom floppy audio silly
mrroach@flmrroach:~$ cat /tmp/sillyfile
mrroach@flmrroach:~$ echo lalalala >> /tmp/sillyfile
mrroach@flmrroach:~$ cat /tmp/sillyfile
lalalala
mrroach@flmrroach:~$ newgrp lp
mrroach@flmrroach:~$ cat /tmp/sillyfile
lalalala
mrroach@flmrroach:~$ groups
lp mrroach cdrom floppy audio silly
mrroach@flmrroach:~$ ls -l /tmp/sillyfile
-rwxrwx---    1 root     silly           9 Aug 14 18:04 /tmp/sillyfile


I think you are mistaken...

-Mark



Reply to: