Specifying permissions with octal numbers, Permission combinations in octal numbers – HP NonStop G-Series User Manual

Page 127

Advertising
background image

You can also use an absolute assignment to remove permissions. In the following example, the
command chmod a=rw file3 assigns read (r) and write (w) permission and removes the execute
permission (x) for all groups (a) from the file file3:

$ chmod a=rw file3

$ ls -l file3

-rw-rw-rw- 1 larry system 130 Jun 5 10:06 file3

Specifying Permissions With Octal Numbers

You can use octal numbers to change file and directory permissions. To use octal permission codes
with the chmod command, enter the command in the following form:

chmod octalnumber filename

The octalnumber entry is a four-digit octal number. The rightmost three digits specify the
permissions for owner, group, and others. The leftmost digit sets the user ID (setuid), group ID
(setgid), and sticky bits. The filename entry is the name of the file whose permissions you want
to change. It can be the name of the file or a list of filenames separated by spaces. You can also
use pattern-matching characters to specify files.

An octal digit corresponds to each type of permission:

4 = r (read) permission

2 = w (write) permission

1 = x (execute) permission

0 = - (no permission)

The leftmost digit of octalnumber sets the setuid, setgid, and sticky bits as follows:

4 = setuid bit

2 = setgid bit

1 = sticky bit

To specify a group of permissions (a permissions field), add together the appropriate octal values.
For example:=,

-wx=

2 + 1=3

rw-=

4 + 2=6

rwx=

4 + 2 + 1=7

---

= no permissions=0

Table 19

lists the eight possible permission combinations.

Table 19 Permission Combinations in Octal Numbers

Description

Permissions

Octal Number

No permissions granted

---

0

Execute

--x

1

Write

-w-

2

Write and execute

-wx

3

Read

r--

4

Read and execute

r-x

5

Read and write

rw-

6

Read, write, and execute

rwx

7

Setting File and Directory Permissions (chmod)

127

Advertising
This manual is related to the following products: