GeneralThis forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
It says if I have write permission on directory, I will be able to add, rename, and delete files in the directory. The truth is not. I tested, it really need the execute permission, too, to be able to add, rename, and delete. So many information out there are wrong, this one, too: https://help.ubuntu.com/community/FilePermissions
Another weird thing is, if I have all read, write, execute permission to this directory. Even the files inside only has read permission, I can still edit them no problem. I used vim to edit, and to :w! to save them, and it works. Why is that?
It says if I have write permission on directory, I will be able to add, rename, and delete files in the directory. The truth is not. I tested, it really need the execute permission, too, to be able to add, rename, and delete.
Please give a specific example? No one here knows what you're seeing/doing,
so it's hard to say why what is going on.
Quote:
Another weird thing is, if I have all read, write, execute permission to this directory. Even the files inside only has read permission, I can still edit them no problem. I used vim to edit, and to :w! to save them, and it works. Why is that?
What cpthk is saying is true, really. What it says is to cd into the directory you have to have execute permission, but to change/create/remove files from the directory you have to have write permission.
If you have write permission and try to change/create/remove files from the directory without also having execute permission, you can't do it.
Quote:
write
(create or remove files from dir)
w or 2
execute
(cd into directory)
x or 1
---
As far as having read permission only on the file and using vim and :w!, it forces a write. You don't have to use :w! if you have write permission.
When using vim in this situation and editing a file, it will say at the bottom:
Quote:
W10: Warning: Changing a readonly file
When you try to write with :w, it will give the message:
Quote:
E45: 'readonly' option is set (add ! to override)
Then you override it with :w!
That's all you're doing, is overriding it.
Please give a specific example? No one here knows what you're seeing/doing,
so it's hard to say why what is going on.
I already gave example, I gave the website showing I only need write permission to add, rename, delete. But the truth is not.
No, I am not running as root.
Quote:
Originally Posted by joeBuffer
Then you override it with :w!
That's all you're doing, is overriding it.
But isn't file system suppose to enforce file security? If I can easily do override, then any virus or spyware could do it too. So you were saying vim ignore the file permission? What is the condition vim could override the permission? I suppose vim shouldn't override the permission in the case that those files really need to be protected.
My vim will do it fine. And why not? I own the file. vim can chmod write permissions onto it, write to the file, and them chmod them off. Files owned by root... that's another story.
My vim will do it fine. And why not? I own the file. vim can chmod write permissions onto it, write to the file, and them chmod them off. Files owned by root... that's another story.
I don't know the details, but this is what I've assumed happens.
Code:
joebuffer@ubuntu:~$ cd test
joebuffer@ubuntu:~/test$ touch abc.txt; chmod 0400 abc.txt
joebuffer@ubuntu:~/test$ ls -l
total 0
-r-------- 1 joebuffer joebuffer 0 2009-09-03 17:50 abc.txt
joebuffer@ubuntu:~/test$ vim abc.txt
joebuffer@ubuntu:~/test$ ls -l
total 4
-r-------- 1 joebuffer joebuffer 4 2009-09-03 17:51 abc.txt
joebuffer@ubuntu:~/test$ cat abc.txt
abc
W10: Warning: Changing a readonly file
E45: 'readonly' option is set (add ! to override)
"abc.txt" 1L, 4C written
It must be something they added in more recent versions...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.