write permission on a dir change the owner
I am using Fedora Linux
I created 2 users:
stewie : stewie, family
(stewie belongs to 2 groups)(stewie is the default group)
brian : users, family
(brian also belongs to 2 groups)(users is the default group)
Under root, I did the followings:
- Create directory /share/family
mkdir -p /share/family
- Change the group ownership recursively:
chgrp -R family /share/family
- Set gid bit on the /share/family dir:
chmod g+s /share/family
- Specify full permission for group family & no permissions for others
chmod -R g=rwx,o= /share/family
Then, at brian's terminal (after "su" to brian)
- I created a file: bri_f1. Check using "ls -l" -> it has only "r" permission for group family
Then, at stewie's terminal (after "su" to stewie)
- I created a file: ste_f1. Check using "ls -l" -> it has "rw" permissions for group family
So the 1st question is: why are the permissions different for files created by brian and stewie???
After that, at stewie's terminal, I modified the content of bri_f1 using "vi". I couldn't save the file because this is a read-only file. However, if I use :x!, I can override it. And if I "ls -l", the owner of the file bri_f1 has been changed to stewie (previously, it was of brian)
So, the 2nd question is: stewie doesn't have write permission on the file bri_f1; however, stewie can override it, and make the owner become himself. Why is that?
Thank you for any help.
Last edited by echipbk; 09-11-2012 at 06:23 PM.
|