LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 02: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, 09:44 AM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
give us the output of
Code:
ls -al /doc
please.
 
Old 06-12-2015, 09: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, 09:11 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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 09:18 AM.
 
  


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 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 03:14 PM
[SOLVED] Most convenient owner:group owner for directories in /home/regular_user? stf92 Slackware 2 10-26-2014 08:12 AM
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 - Newbie

All times are GMT -5. The time now is 03:23 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