LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-12-2015, 03:42 AM   #1
somorg
LQ Newbie
 
Registered: Dec 2009
Posts: 3

Rep: Reputation: 0
Lightbulb change of owner and group owner of a file belongs to diff user ?


Can anyone explain ?

Hi,
(Red Hat Linux 7)
#mkdir /doc
#chmod 777 /doc
user1$ cd /doc
user1$ touch file1
{here the owner and group owner of the file is user1}

user2$ cd /doc
user2$ vim file1
{user2 is able to add content and save the file.}

1. After user2 edited the file1 with "vim" the owner of the file get changed why?
2. file1 was created my user1 and having 664 perm by default and user1 is the owner and groupowner of the file. How user2 was able to edit it with the file having only read perm for others ?
 
Old 06-12-2015, 10:44 AM   #2
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,159
Blog Entries: 10

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
give us the output of
Code:
ls -al /doc
please.
 
Old 06-12-2015, 10:50 AM   #3
ongte
Member
 
Registered: Jun 2009
Location: Penang, Malaysia
Distribution: Mageia, CentOS, Ubuntu
Posts: 468

Rep: Reputation: 72
This is because the directory permissions allowed user2 to overwrite the file. Although user2 only had read permisson on the file, when saving it could not be saved in-place, so it used the write permission on the directory to overwrite the file, thats why the owner changes. Write permission on a directory allows creation and deletion of files in that directory regardless of the file permission itself.
 
1 members found this post helpful.
Old 06-14-2015, 10:11 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Quote:
Originally Posted by somorg View Post
Can anyone explain ?

Hi,
(Red Hat Linux 7)
#mkdir /doc
#chmod 777 /doc
user1$ cd /doc
user1$ touch file1
{here the owner and group owner of the file is user1}

user2$ cd /doc
user2$ vim file1
{user2 is able to add content and save the file.}

1. After user2 edited the file1 with "vim" the owner of the file get changed why?
The owner changed because vim deleted the original file (or renamed it to a backup) and created a new file.
Quote:
2. file1 was created my user1 and having 664 perm by default and user1 is the owner and groupowner of the file. How user2 was able to edit it with the file having only read perm for others ?
a. The directory permissions 777 allows ANYONE to delete a file. There are no protections.
b. user2 was allowed to read the file, and create a new file. From item "a", that user is also allowed to delete/rename the file before creating a new file there.

You should look into what the "sticky" bit is for (for example, how it is used for /tmp).

BTW, you might also look into using "git" for documentation version control... That would allow you to determine who can make changes, as well as resolve collision when two or more make edits to the same file without loosing edits. It also allows you a "undo" to make it simple to revert changes.

There is also a "gitfs" that can be used to provide a filesystem access to the data (https://github.com/PressLabs/gitfs and scroll down to see what it is).

Last edited by jpollard; 06-14-2015 at 10:18 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
change file owner to another owner byran cheung Linux - Newbie 5 12-19-2014 04:14 PM
[SOLVED] Most convenient owner:group owner for directories in /home/regular_user? stf92 Slackware 2 10-26-2014 09:12 AM
Change owner, group and permission settings on file and folder creation?? helptonewbie Linux - Newbie 9 12-17-2007 04:03 PM


All times are GMT -5. The time now is 10:24 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration