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 rxw

Permissions can be indicated by mnemonic or octal characters. Mnemonic characters are

• 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 permissions, 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 be different! This is because of umask settings assigned by the shell.

Many users prefer to represent permissions using 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.

Was this article helpful?

0 0

Post a comment