Java Reference
In-Depth Information
permission, and the least significant bit is execute permission. If you think of
the three categories, user/group/others, as three digits, then you can express the
permissions of a file as three octal digits, for example “750”. The earliest ver-
sions of this command required you to set file permissions this way, by specify-
ing the octal number. Now, although there is a fancier syntax (for example,
g+a ), you can still use the octal numbers in the chmod command. See the
example below.
The fancier, or more user-friendly, syntax uses letters to represent the var-
ious categories and permissions. The three categories of user, group, and other
are represented by their first letters: u , g , and o . The permissions are similarly
represented by r , w , and x . (OK, we know “x” is not the first letter, but it is a
reasonable choice.) For both categories and permissions, the letter a stands for
“all.” Then, to add permissions, use the plus sign ( + ); to remove permissions,
use the minus sign ( - ). So g+a means “add all permissions to the group catego-
ry,” and a+r means “add read permissions to all categories.”
Be sure that you know these commands for manipulating permissions:
chmod changes the mode of a file, where mode refers to the
read/write/execute permissions.
chown changes the owner of a file. 4
chgrp changes the group owner of a file.
Table 1.1 shows some common uses of these commands.
Table 1.1 Changing permissions
Command
Explanation
chmod a+r file
Gives everyone read permission.
chmod go-w file
Takes away write permission from group, others.
chmod u+x file
Sets up a shell script so you can execute it like a command.
chmod 600 file
Sets permission to read and write for the owner but no permissions
for anyone else.
4. On Linux the use of this command is restricted to the superuser, or “root.”
Search WWH ::




Custom Search