Changing owners and groups, Changing owners – HP NonStop G-Series User Manual

Page 130

Advertising
background image

read and execute permissions. However, because you have previously set a user mask of 037,
that further restricts the file permissions. As a result, the owner still has all permissions, but the
group cannot execute the file and all others have no permissions.

You can activate the umask command in two ways:

Include it in your .profile file. This is the most common and efficient way to specify your
user mask, because the specified value is set automatically for you whenever you run osh.

Enter it at the shell prompt. The user mask value you set is in effect for the duration of the shell
session.

For a more detailed example of how your user mask works in restricting permissions for files you
create with a text editor, you can perform the following procedure:
1.

Enter the following command to find out what the current value of your user mask is:

$ umask

If the user mask value is 000, there are no restrictions on the permissions established by
file-creating programs. Go to Step 3.

If the user mask value has another value, note that value and go to Step 2.

2.

Set the user mask value to 000 so that there will be no restrictions on the permissions established
by file-creating programs. Before setting the user mask to 000, make sure you have written
down the current value, should you need to restore it.

Enter the following:

$ umask 000

3.

Create the file afile, save it, and then exit your editor.

4.

Display the permissions of the file by using the ls -l command. Assume for the sake of the
example that read and write permissions are granted for all users:

$ ls -l afile

-rw-rw-rw- 1 user 15 Oct 27 14:42 afile

5.

Change the user mask to 022 by entering the following:

$ umask 022

A user mask of 022 establishes the following maximum permission restrictions: owners are
allowed all permissions, and all others are allowed only read and execute permissions.

6.

Create another file afile2, save it, and then exit your editor.

7.

Display the permissions of the file afile2 by using the ls -l command.

$ ls -l afile2

-rw-r--r-- 1 user 15 Oct 27 14:42 afile2

Note that the write permissions for the group and all others have been removed in accordance
with the user mask value of 022.

8.

Change the user mask to its original value or to another value (optional).

Open System Services provides a default user mask value of 022, which allows the owner all
permissions but prevents members of your group or any other users from writing to your files.
However, your system’s default user mask may vary.

Changing Owners and Groups

In addition to setting permissions, you can control how a file or directory is used by changing its
owner or group. Use the chown command to change the owner and the chgrp command to
change the group. To use the chown command, you must have the same privileges as a super-group
user. Enter the chown command in the following form:

chown owner filename

130 Managing Access to Files and Directories

Advertising
This manual is related to the following products: