If a file had write permissions only, how could a user exercise his right to edit the file if he could not read it?
Does 'write' imply 'read' in Unix?
Read, write, execute permissions in Unix/Linux are independent. It's possible to have write permissions without the read permission. For binary files, you might have seen that read permission isn't granted but execute permission enables you to execute it. On the other hand, a shell script or any other file that needs to be interpreted needs read permissions in order to execute.
Simply providing write permissions without read would enable you to write (also delete) the file without being able to read it.
The following should be self-explanatory:
$ touch foo
$ ls -l foo
-rw-rw-r-- 1 devnull devnull 0 Jul 19 12:00 foo
$ chmod -r foo
$ ls -l foo
--w--w---- 1 devnull devnull 0 Jul 19 12:00 foo
$ cat foo
cat: foo: Permission denied
$ echo hey > foo
$ ls -l foo
--w--w---- 1 devnull devnull 4 Jul 19 12:00 foo
$ cat foo
cat: foo: Permission denied
$ > foo
$ ls -l foo
--w--w---- 1 devnull devnull 0 Jul 19 12:00 foo
$ rm -f foo
$ ls -l foo
ls: cannot access foo: No such file or directory
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With