Installation guide
118 Chapter 11. Shell Prompt Basics
11.14.1. The chmod Command
Use the chmod command to change permissions easily. This example shows how to change the per-
missions on sneakers.txt with the chmod command.
The original file looks like this, with its initial permissions settings:
-rw-rw-r-- 1 sam sam 150 Mar 19 08:08 sneakers.txt
If you are the owner of the file or are logged into the root account you can change any permissions for
the owner, group, and others.
Right now, the owner and group can read and write to the file. Anyone outside of the group can only
read the file (r--).
Caution
Remember that file permissions are a security feature. Whenever you allow anyone else to read, write
to, and execute files, you are increasing the risk of files being tampered with, altered, or deleted. As
a rule, you should only grant read and write permissions to those who truly need them.
In the following example, you want to allow everyone to write to the file, so they can read it, write
notes in it, and save it. That means you will have to change the "others" section of the file permissions.
Take a look at the file first. At the shell prompt, type:
ls -l sneakers.txt
The previous command displays this file information:
-rw-rw-r-- 1 sam sam 150 Mar 19 08:08 sneakers.txt
Now, type the following:
chmod o+w sneakers.txt
The o+w command tells the system you want to give others write permission to the file sneak-
ers.txt. To check the results, list the file’s details again. Now, the file looks like this:
-rw-rw-rw- 1 sam sam 150 Mar 19 08:08 sneakers.txt
Now, everyone can read and write to the file (Figure 11-10).