No, write permission does not include read permission, the statement in the book is incorrect. These permissions are independent. If you have write permission only, you can overwrite the file, but you cannot read it. If you have read permission only, you can read the file, but you cannot overwrite it. If you have both permissions, you can do both.
Here is an example. We have a directory with three files, file1
, file2
, and file3
. Each of these files contains a single line of text This is file n
(where n
=1, 2 or 3) and the permissions are as follows:
raj@jarek-02:~/test$ ls -l
total 12
-rw--w--w- 1 root root 15 Jul 26 19:54 file1
-rw-r--r-- 1 root root 15 Jul 26 19:52 file2
-rw-rw-rw- 1 root root 15 Jul 26 19:53 file3
The files are owned by root
, and root
has both read and write permission to all three files, but other users (and I'm currently the user raj
, as you can see from the system prompt) have only write access to first file, only read access to second one and both read/write access to the third one.
As we can expect, I cannot read the first file, but can read the other two:
raj@jarek-02:~/test$ cat file1
cat: file1: Permission denied
raj@jarek-02:~/test$ cat file2
This is file 2
raj@jarek-02:~/test$ cat file3
This is file 3
Let's try to overwrite the files now.
raj@jarek-02:~/test$ echo "Overwriting file 1" > file1
raj@jarek-02:~/test$ echo "Overwriting file 2" > file2
bash: file2: Permission denied
raj@jarek-02:~/test$ echo "Overwriting file 3" > file3
First and third command succeeded (because there was no output), and the second one failed with a "Permission denied" message.
Now try to display the files again:
raj@jarek-02:~/test$ cat file1
cat: file1: Permission denied
raj@jarek-02:~/test$ cat file2
This is file 2
raj@jarek-02:~/test$ cat file3
Overwriting file 3
I still cannot display file1
, although I was able to change it. file2
did not change (as there was a "Permission denied" message when trying to change it), and we can see that file3
did change.
To verify file1
has changed as well, let's try to display it as root
user, who has read access to the file:
root@jarek-02:/home/raj/test# cat file1
Overwriting file 1
So in fact the user raj
, having write access, was able to change the file's contents, but neither before nor after changing it cannot read the file.