Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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:
sudo groupadd test-group
sudo usermod -G test-group -a user1
sudo usermod -G test-group -a user2
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:
chmod 777 test-file1 <- Expected to fail
chmod 777 test-file1 <- Expected to succeed
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!
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?'
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.
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.
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!