Previous | Table of Contents | Next |
Many user problems can be traced to file ownership or permissions problems. Use the ls command to check the permissions and ownership on a file. If you need to change one or both, use the chown, chmod, and chgrp commands.
Changing File Ownership You must own a file or directory (or have root permission) to be able to change its owner:
oak% ls -l quest -rw-r--r-- 1 fred staff 6Ø23 Aug 5 12:Ø6 quest oak% su Password: # chown ignatz quest # ls -l quest -rw-r--r-- 1 ignatz staff 6Ø23 Aug 5 12:Ø6 quest #
See Chapter 10, "Recognizing File Access Problems," for more information.
Changing File Permissions You can change file permissions by using the symbolic values r, w, x, and -. You can also change file permissions by using a set of octal numbers. Table 1-8 shows the octal values for setting file permissions. You use these numbers in sets of three to set permissions for owner, group, and other. For example, the value 644 sets read /write permissions for owner and read-only permissions for group and other.
Value | Description |
---|---|
0 | No permissions |
1 | Execute-only |
2 | Write-only |
3 | Write, execute |
4 | Read-only |
5 | Read, execute |
6 | Read, write |
7 | Read, write, execute |
NOTE: You can change permissions on groups of files, or on all files in a directory using metacharacters such as (*?) in place of file names or in combination with them.
This example changes the permissions of a file from 666 (read/write, read/write, read/write) to 644 (read/write, read-only, read-only):
oak% ls -l quest -rw-rw-rw- 1 ignatz staff 6Ø23 Aug 5 12:Ø6 quest oak% chmod 644 quest oak% ls -l -rw-r--r-- 1 ignatz staff 6Ø23 Aug 5 12:Ø6 quest oak%
To change the group ownership of a file, type chgrp gid filename and press Return. The group ID for the file you specify is changed:
$ ls -lg junk -rw-r--r-- 1 other Ø Oct 31 14:49 junk $ chgrp 1Ø junk $ ls -lg junk -rw-r--r-- 1 staff Ø Oct 31 14:49 junk $
Group IDs are defined in the Group database or the local /etc /group file. See Chapter 7, "Administering User Accounts and Groups," for more information about groups.
The shell maintains an environment with a set of specifications that it gets from the shell initialization files. Users can also modify the shell environment for a session by issuing commands directly to the shell. The shell receives its information about the environment from environment variables. The SunOS 5.x system software provides several default environment variables:
Previous | Table of Contents | Next |