248 You Are Here
Tip: Remember that file permissions are a security feature. Whenever you allow every-
onetoread,writetoandexecutefiles, you may be increasing your risk of tampering. As
a rule, then, you should shy away from allowing everyone to read and write to a file.
In this case, however, let’s say that we want to allow everyone to write to the file, so they can read it,
write notes in it and save it. That means we’ll have to change the change the “others” section of the
file permissions.
Since we’re the owner of the file, we don’thavetosu to root to do it. Let’s take a look at the file first.
At the shell prompt, type:
ls -l sneakers.txt
which gives us this file information:
-rw-rw-r-- 1 billy billy 150 Mar 19 08:08 sneakers.txt
Now, type the following:
chmod o+w sneakers.txt
To check our results, we can list the file’s details again. Now, the file looks like this:
-rw-rw-rw- 1 billy billy 150 Mar 19 08:08 sneakers.txt
There’s our result: Now, everyone can read and write to the file (Figure 16.18).
When we typed o+w,weweresaying,“for others, add write permission to the file sneakers.txt.”
If we want to remove all access permission from sneakers.txt (eventhoughit’sonlyasketchy
shopping list), we could use the chmod command to take away both the read and write permissions
like so:
chmod go-rw sneakers.txt
and the result will look like this:
-rw------- 1 billy billy 150 Mar 19 08:08 sneakers.txt
Comments to this Manuals