LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-11-2012, 06:18 PM   #1
echipbk
LQ Newbie
 
Registered: Feb 2012
Posts: 13

Rep: Reputation: Disabled
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.
 
Old 09-12-2012, 05:48 AM   #2
segmentation_fault
Member
 
Registered: Sep 2008
Location: Ioannina, Greece
Distribution: Gentoo
Posts: 332

Rep: Reputation: 55
Quote:
So the 1st question is: why are the permissions different for files created by brian and stewie???
Because brian and stewie (we aren't talking about Family Guy, right? ) are different users. I might missed something, so it would be better if you pasted exactly the output of the commands you ran in code tags.

Quote:
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?
stewie has write permissions on the directory containing the file, so he can delete/move/overwrite any file inside that directory. When you add "!" in your vim command, it doesn't write on the original file, it creates a new one discarding the brian's file.

Here is a recent thread that you should read on that topic.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I change the owner or get read/write access to my hd? hate29 Linux - Newbie 6 02-11-2008 12:30 PM
Can't change folder permission - owner is "33" kfogalin Linux - Newbie 2 01-30-2008 03:07 PM
Change owner, group and permission settings on file and folder creation?? helptonewbie Linux - Newbie 9 12-17-2007 03:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration