Red Hat ENTERPRISE LINUX 3 - STEP BY STEP GUIDE Manual page 59

Table of Contents

Advertisement

Chapter 3. Shell Prompt Basics
3.13.2. Changing Permissions With Numbers
Remember the reference to the shorthand method of
sions, although it may seem a little complex at first.
Go back to the original permissions for
-rw-rw-r--
1 sam sam
Each permission setting can be represented by a numerical value:
r = 4
w = 2
x = 1
- = 0
When these values are added together, the total is used to set specific permissions. For example, if you
want read and write permissions, you would have a value of 6; 4 (read) + 2 (write) = 6.
For
, here are the numerical permissions settings:
sneakers.txt
-
(rw-)
(rw-)
|
|
4+2+0
4+2+0
The total for the user is six, the total for the group is six, and the total for others is four. The permissions
setting is read as
664
If you want to change
read the file, remove the access by subtracting two (2) from that set of numbers.
The numerical values then become six, four, and four (644).
To implement these new settings, type:
chmod 644 sneakers.txt
Now verify the changes by listing the file. Type:
ls -l sneakers.txt
The output should be:
-rw-r--r--
1 sam sam
Now, neither the group nor others have write permission to
write access for the file, add the value of w (2) to the second set of permissions.
chmod 664 sneakers.txt
Warning
Setting permissions to 666 allows everyone to read and write to a file or directory. Setting permis-
sions to 777 allows everyone read, write, and execute permission. These permissions could allow
tampering with sensitive files, so in general, it is not a good idea to use these settings.
sneakers.txt
150 Mar 19 08:08 sneakers.txt
(r--)
|
4+0+0
.
so those in your group do not have write access, but can still
sneakers.txt
150 Mar 19 08:08 sneakers.txt
? Here is another way to change permis-
chmod
:
sneakers.txt
45
. To return the group's

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 3

Table of Contents