Книга: Fedora™ Unleashed, 2008 edition

Assigning Permissions

Assigning Permissions

Under Linux, permissions are grouped by owner, group, and others, with read, write, and execute permission assigned to each, like so:

Owner Group Others
rwx   rwx   rwx

Permissions can be indicated by mnemonic or octal characters. You can use the following mnemonic characters:

r indicates permission for an owner, member of the owner's group, or others to open and read the file.

w indicates permission for an owner, member of the owner's group, or others to open and write to the file.

x indicates permission for an owner, member of the owner's group, or others to execute the file (or read a directory).

In the previous example for the file named file, the owner, andrew, has read and write permission, as does any member of the group named andrew. All other users may only read the file. Also note that default permissions for files created by the root operator will differ! This happens because of umask settings assigned by the shell.

Many users prefer to represent permissions with numeric codes, based on octal (base 8) values. Here's what these values mean:

4 indicates read permission.

2 indicates write permission.

1 indicates execute permission.

In octal notation, the previous example file has a permission setting of 664 (read + write or 4 + 2, read + write or 4 + 2, read-only or 4). Although you can use either form of permissions notation, octal is easy to use quickly after you visualize and understand how permissions are numbered.

NOTE

In Linux, you can create groups to assign a number of users access to common directories and files based on permissions. You might assign everyone in accounting to a group named accounting, for example, and allow that group access to accounts payable files while disallowing access by other departments. Defined groups are maintained by the root operator, but you can use the newgrp command to temporarily join other groups to access files (as long as the root operator has added you to the other groups). You can also allow or deny access to your files by other groups by modifying the group permissions of your files.

Оглавление книги


Генерация: 1.124. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз