Linux Configuration and Installation:Basic Linux Tools
-->
Previous
Table of Contents
Next
Changing Permissions
The Linux command chmod changes file permissions. You may want to change permissions for some popular directories in order to avoid logging in as root to install or configure software.
NOTE: Unless you have write permission for a file or directory, you cant change the permissions. Of course, this means that you need to be logged in as root in order to change permissions.
Permissions can be changed in numeric or symbolic form. Neither method is what could be called intuitive, so well spend some time explaining each of them.
The Numeric Method
The numeric method uses numbers to track permissions. Like the permissions listings earlier in this section, the numeric method divides permissions into threes, albeit in a different manner.
The numeric method forces you to add three different sets of numbers in determining who has which permissions. The actual types of permissions (owner, group, world) havent changedonly the method of listing them.
Youll use modes to track permissions, as seen in Table 4.3.
Table 4.3 Modes and Their Meanings
Mode
Meaning
400
Owner has read permission.
200
Owner has write permission.
100
Owner has execute permission.
040
Group has read permission.
020
Group has write permission.
010
Group has execute permission.
004
World has read permission.
002
World has write permission.
001
World has execute permission.
You must now translate these numbers into the numeric form by adding them together. For example, using the following directory listing:
-rwxxx 1 kevinr group1 854 Apr 2 19:12 test
we arrive at a numeric permission of 711:
400
Owner has read permission.
200
Owner has write permission.
100
Owner has execute permission.
010
Group has execute permission.
001
World has execute permission.
711
A file or directory thats totally open to the world would have a permission of 777; a file or directory inaccessible to anyone would have a permission of 000.
Changing the permissions entails combining the desired permissions with the chmod command. For example, to change the file permissions of the test command to make it totally accessible to all users, youd use the following command line:
gilbert:/$ chmod 777 test
To change the permissions so that only the owner of the file has the ability to totally access the file and at the same time permission is denied to every other user, youd use the following command line:
gilbert:/$ chmod 700 test
To change the permissions so that the owner of the file has the ability to totally access the file, but other users and the group have the ability to read and execute (but not change) the file, youd use the following command line:
gilbert:/$ chmod 744 test
The Symbolic Method
When using the numeric method, you dont need to know the existing permissions of the file, which means that you need enter only the desired permissions. The other main method of setting permissions, called the symbolic method, requires that you know the existing permissions, as youre setting new permissions relative to the existing permissions.
The symbolic method eschews numerals and uses letters instead. And its very precise in adding or subtracting permissions relative to existing permissions. For example, the following command line gives execute permissions to the world (all users):
gilbert:/$ chmod o+x data
Here, o refers to others (in chmod parlance, the world), x refers to execute permission, and the plus sign (+) adds the execute permission to others. If a minus sign (-) were used, this command line would remove execute permission from others.
The symbolic method uses some quirky language, as youve already seen with the reference to others. The owner of the file is referred to as the user, and setting permissions for the owner means using u:
gilbert:/$ chmod u+x data
Setting the permission for the group is a matter of using g:
gilbert:/$ chmod g+x data
These statements, of course, would be meaningless if the users already had the ability to execute the file.
Table 4.4 lists the various symbols used with the chmod command.
Table 4.4 Symbols Used with the Symbolic Method
Symbol
Meaning
u
User (owner of the file).
g
Group.
o
Other (the world).
a
Everyone (the owner, the group, and the world).
+
Adds permission.
-
Removes permission.
r
Read permission.
w
Write permission.
x
Execute permission.
t
Sets the sticky bit on a directory.
NOTE: If you create your own shell scripts or use the Perl language, youll need to set permissions to make your scripts usable.
Previous
Table of Contents
Next
Wyszukiwarka
Podobne podstrony:
208 09 (2)14 (208)INDEX (208)20 (212)04 (208)ZEUS 208 WG208 04więcej podobnych podstron