LinuxQuestions.org
Review your favorite Linux distribution.
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 11-26-2008, 10:53 AM   #1
RomeoJava
LQ Newbie
 
Registered: Nov 2008
Distribution: Ubuntu
Posts: 2

Rep: Reputation: 0
Question Linux file permissions question


Hello all,

When I've given files permissions such as 775 so members of the same group can read, write and execute a file I've always assumed that they could write to the file itself and also to the file's permissions. However now I've tried it this doesn't seem to be the case. I can't find any references on the net specifically explaining this though. Is it true to say that 'Only the owner or root can change a file's permissions even if other users have write permissions?' The test I did was something along the lines of:

As user1:
sudo groupadd test-group
sudo usermod -G test-group -a user1
sudo usermod -G test-group -a user2
touch test-file1
newgrp test-group
touch test-file2
chmod 775 test-file*
ls -l test-file*

-rwxrwxr-- 1 user1 user1 0 Nov 26 15:39 test-file1
-rwxrwxr-- 1 user1 test-group 0 Nov 26 15:40 test-file2

Then as user2:
newgrp test-group
cd /home/user1
chmod 777 test-file1 <- Expected to fail
chmod 777 test-file1 <- Expected to succeed

Results:
chmod: changing permissions of `test-file1': Operation not permitted
chmod: changing permissions of `test-file2': Operation not permitted


Any help, such as a link to confirm my understanding is correct would be most appreciated!

Rj :-)
 
Old 11-26-2008, 11:03 AM   #2
Cichlid
Member
 
Registered: Jan 2002
Location: Montreal
Distribution: Ubuntu 8.10
Posts: 178

Rep: Reputation: 30
I noticed that user2 was trying to work with the file in /home/user1. I wonder if this is the root of the problem.
Myself, I've created a new directory in /home for both users to read and write in.
 
Old 11-26-2008, 11:05 AM   #3
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,040

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
Quote:
Originally Posted by RomeoJava View Post
Hello all,

When I've given files permissions such as 775 so members of the same group can read, write and execute a file I've always assumed that they could write to the file itself and also to the file's permissions. However now I've tried it this doesn't seem to be the case. I can't find any references on the net specifically explaining this though. Is it true to say that 'Only the owner or root can change a file's permissions even if other users have write permissions?'
Yes.

I haven't ever looked on the cause why this is this way. However, note that on tipical filesystems the attributes are inserted in the file system, not in the file itself. So, granting you access (even write access) into the file doesn't necessarily grant you any right over the attributes, which are stored into a separate place.
 
Old 11-26-2008, 02:39 PM   #4
sfjoe
Member
 
Registered: Jun 2007
Location: San Francisco
Distribution: Centos 4, Debian
Posts: 55

Rep: Reputation: 16
It make sense. If anyone who had write permissions could alter the file permissions, then anyone in your group could (accidentally or otherwise) change your file from 775 to 777. Or, they could do 470 and lock you out from making changes. If you had wanted the file to be 777, you would have done so yourself. Anything else would be a security risk.
 
Old 11-26-2008, 03:47 PM   #5
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,040

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
Yup. That's the whole point of permissions. If anyone with write permission could override them why set them in first place.
 
Old 11-27-2008, 03:07 AM   #6
RomeoJava
LQ Newbie
 
Registered: Nov 2008
Distribution: Ubuntu
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for all your help, it seems as though this is the way it works although I'll try Cichlid's idea just to double check. I have to admit I'm very surprised that nobody has mentioned any documentation which explains what I consider to be a very fundamental part of Linux security, very odd!

Rj
 
Old 11-27-2008, 03:17 AM   #7
sadiqdm
Member
 
Registered: Nov 2003
Location: London, UK
Distribution: openSUSE, Ubuntu
Posts: 357

Rep: Reputation: 35
This is a good reference page for how Linux permissions work - http://www.comptechdoc.org/os/linux/..._ugfilesp.html
 
  


Reply

Tags
groups, ownership, permissions, undefined


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
Windows file permissions with a Linux file server joseph_k Linux - Server 3 05-09-2008 12:54 PM
File/Directory Permissions Question nyle Linux - Newbie 2 05-08-2008 01:57 PM
Help on Linux File Permissions kool_kid Linux - Server 6 03-11-2008 08:04 AM
Question about linux file permissions (+ in mode) bagpussnz Linux - General 1 08-06-2007 07:55 PM
Folder/File Permissions Question? gsmonk Linux - General 8 07-20-2003 03:08 AM


All times are GMT -5. The time now is 03:19 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration