Setting the user mask – HP NonStop G-Series User Manual

Page 128

Advertising
background image

The entire permission code for a file or directory is specified with a four-digit octal number, one
digit each for owner, group, and others, and one digit (leftmost) for the setuid, setgid, and sticky
bits (you can omit leading zeros).

Table 20

shows some typical octal permission codes and how

they relate to the permission fields.

Table 20 How Octal Permission Codes Relate to Permission Fields

Complete Code

Others Field

Group Field

Owner Field

Octal Number

rwxrwxrwx

rwx

rwx

rwx

0777

rwxr-xr-x

r-x

r-x

rwx

755

rwx------

---

---

rwx

700

rw-rw-rw-

rw-

rw-

rw-

666

rwsr-xr-x

r-x

r-x

rws

4755

Enter the following example to change the permission of file3 to -rwxr-xr-- using octal
numbers:

$ ls -l file3

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

$ chmod 754 file3

$ ls -l file3

-rwxr-xr-- 1 larry system 130 Jun 5 10:06 file3

Setting the User Mask

Every time you create a file or a directory, the program you are running automatically establishes
a default permission code for it. This relieves you from the task of specifying a permission code
explicitly every time you create a file or directory.

If you wish to further restrict whatever permissions are established by a program when it creates
a file or directory, you must specify a user mask with the umask command. The user mask is a
numeric value that determines the maximum access permissions when a file or directory is created.
As a result, when you create a file or directory, its permissions are set to what the creating program
specifies, minus what the umask value forbids.

The umask command has the following format:

umask octalnumber

The octalnumber entry is a 3-digit octal number that specifies the default maximum permissions
for owner, group, and others.

Setting the user mask is very similar to setting the permission code using octal numbers, discussed
in

“Specifying Permissions With Octal Numbers” (page 127)

. The permission code for a file or

directory is specified with a three-digit octal number. Each octal digit represents a type of permission.
The position of each octal digit (first, second, or third) corresponds as follows:

The first position is for the owner of the file (you).

The second position is for the group of the file.

The third position is for the default class, others.

When you set the user mask, you are actually specifying which permissions are not to be granted,
regardless of the permissions requested by the file-creating program.

The three bits of each octal digit have these meanings:

4=no read permission

128

Managing Access to Files and Directories

Advertising
This manual is related to the following products: