Linux file/directory permission question
Hi:
I read many documentation out there, many seems to be incorrect. For example this one: http://www.zzee.com/solutions/linux-...k_9_1077830297 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? Thanks. |
Quote:
so it's hard to say why what is going on. Quote:
|
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:
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:
Quote:
That's all you're doing, is overriding it. Look here: http://www.tuxfiles.org/linuxhelp/filepermissions.html |
Quote:
No, I am not running as root. Quote:
|
You're right that you need execute permission on a directory to be able to do anything in it.
joeBuffer is incorrect, w! will not force a write on a read only file. If you try it, it will give you an error message The result of w! on a readonly file abc.txt Code:
abc.txt unwritable |
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.
|
Quote:
about some web-tutorial this thread is going to GENERAL. Cheers, Tink |
OK, in my case it's elvis (on Slackware 10.1; vi is symlinked to it), not vim. I always forget about the difference :doh:
The result of :w in vim Code:
"abc.txt" Code:
"abc.txt" And the permissions: Code:
wim@btd-techweb01:~/test$ ls -l |
I have file permission:
Code:
-r-------- test test file Code:
:w Code:
:w! |
Quote:
Code:
joebuffer@ubuntu:~$ cd test E45: 'readonly' option is set (add ! to override) "abc.txt" 1L, 4C written It must be something they added in more recent versions... |
You can modify vim's behaviour using the W flag in cpoptions
|
Keep in mind that the type of filesystem and the mount options(if on a separate partition) will affect your ability to read/write files also.
|
All times are GMT -5. The time now is 12:47 AM. |