Setting file and directory permissions (chmod) – HP NonStop G-Series User Manual

Page 124

Advertising
background image

-rw-r--r-- 1 larry system 0 Jun 5 11:03 record1

-rw-r--r-- 1 larry system 0 Jun 5 11:03 record6

drwxr-xr-x 2 larry system 32 Jun 5 10:31 reports

The first string of each entry in the directory shows the permission code for that file or directory.
For example, the fourth entry, drwxr-xr-x, shows the following:

This is a directory (the d notation).

The owner can view it, write in it, and search it (the rwx sequence).

The group can view it, cannot write in it, but can search it (the first r-x sequence).

All others can view it, cannot write in it, but can search it (the second r-x sequence).

The third column shows the file’s owner (in this case, larry), and the fourth column shows the
group to which the file belongs (in this case, system).

To list the permissions for a single directory, use the ls -ld command:

$ ls -ld reports

drwxr-xr-x 2 larry system 32 Jun 5 10:31 reports

Setting File and Directory Permissions (chmod)

Your ability to change permissions gives you a great deal of control over the way your files and
directories can be used. Use the chmod (change mode) command to set or change the permissions
for your files and directories.

For example, you usually permit yourself (the owner/user) to read, write to, and execute a file.
You generally permit members of your group to read a file. Depending upon the nature of your
work and the composition of your group, you often allow them also to write to it or execute it. You
generally prohibit all other system users from having any access to your files and directories.

You must be the owner of a file or directory to be able to change its permissions. This means that
your user name must be in the third column in an ls -l listing of that file.

There are two ways to specify the permissions set by the chmod command:

You can specify permissions with letters and operation symbols.

You can specify permissions with octal numbers.

It is more difficult to learn to specify permissions with octal numbers than it is to specify them with
letters. However, once you are familiar with the octal number system, you may find using it more
efficient than setting permissions with letters and operation symbols.

The following subsections describe how to specify permissions with letters and operation symbols,
as well as with octal numbers.

NOTE:

The chmod command cannot be used to change the permissions of files in the /G and

the /E directories.

Specifying Permissions With Letters and Operation Symbols

You can use letters and operation symbols to change file and directory permissions. Following is
the format of the chmod command when using letters and operation symbols:

chmod userclass-operation-permission filename

The userclass-operation-permission entry represents codes that specify the user class,
operation, and type of permission that you wish to activate. The filename entry is the name of

124

Managing Access to Files and Directories

Advertising
This manual is related to the following products: