File System Administration
검색에만이 책은
PDF로 이 문서 다운로드

Recognizing File Access Problems

11

This chapter contains these parts:
Recognizing Problems With Search Pathspage 209
Recognizing Problems With Permission and Ownershippage 212
Recognizing Problems With Network Accesspage 215
Users frequently experience problems--and call on a system administrator for help--because they cannot access a program, a file, or a directory that they used to be able to use. Whenever you encounter such a problem, investigate one of three areas:
  • The user's search path may have been changed, or the directories in the search path may not be in the proper order.
  • The file or directory may not have the proper permissions or ownership.
  • The configuration of a system accessed over the network may have changed.
This chapter briefly describes how to recognize problems in each of these three areas and suggests possible solutions.

Recognizing Problems With Search Paths

If a user types a command that is not in the search path, the message Command not found is displayed. The command may not be found because:
  • The command is not available on the system.
  • The command directory is not in the search path.
If the wrong version of the command is found, a directory with a command of the same name is in the search path. In this case, the proper directory may be later in the search path or may not be present at all.
Diagnosing problems with search paths involves these steps:
  1. Displaying the current search path.

  2. Editing the file where the user's path is set (.login or .cshrc for the C shell, .profile for the Bourne and Korn shells). Add the directory to the path definition, or rearrange the order of the directories listed for the path.


Note - For the C shell, always check both the .cshrc and .login files to make sure the path information is set all in one place. Duplicate entries can make the search path hard to troubleshoot and make search times less efficient for the user.

  1. Sourcing the file to activate the changes.

  2. Verifying that the command is found in the right place.

  3. Executing the command.

The tasks you use to follow this procedure are described below.
· How to Display the Current Search Path
* Type echo $PATH and press Return. The current search path is displayed.

  mars% echo $PATH  
  /sbin:/usr/sbin:/usr/bin:/etc  
  mars%  

· How to Set the Path for Bourne and Korn Shells
The path for the Bourne and Korn shells is specified in the user's $HOME/.profile file in this way:

  PATH=.:/usr/bin:/$HOME/bin;export PATH  

· How to Set the Path for the C Shell
The path for the C shell is specified in the user's $HOME/.cshrc file (with the set path environment variable) in this way:

  set path =  (. /usr/bin $home/bin)  

· How to Source C Shell Dot Files
To source the .cshrc file:
* Type source .cshrc and press Return. New information in the file is made available to the shell.
To source the .login file:
* Type source .login and press Return. New information in the file is made available to the shell.
· How to Source Korn and Bourne Shell Dot Files
To source the .profile file:
* Type . .profile and press Return. New information in the file is made available to the shell.
· How to Verify the Search Path
* Type which command-name and press Return. If the command is found in the path, the path and the name of the command are displayed.

Note - The which command looks in the .cshrc file for information. The which command may give misleading results if you execute it from the Bourne or Korn shell and you have a .cshrc file that contains aliases for which. To ensure accurate results, use the which command in a C shell, or, in the Korn shell, use the whence command.

This example shows that the OpenWindows executable is not in any of the directories in the search path:

  venus% which openwin  
  no openwin in . /home/ignatz /sbin /usr/sbin /usr/bin /etc \  
  /home/ignatz/bin /bin /home/bin /usr/etc  
  venus%  

This example shows that the executable for OpenWindows is found among the directories in the search path:

  venus% which openwin  
  /usr/openwin  
  venus%  

If you cannot find a command, look at the manual page. For example, if you cannot find the lpsched command (the lp printer daemon), the lpsched(1M) manual page tells you the path is /usr/lib/lp/lpsched.
· How to Execute a Command
* Type command-name and press Return.

Recognizing Problems With Permission and Ownership

When users cannot access files or directories that they used to be able to access, the most likely problem is that permissions or ownership of the files or directories has changed.
Frequently, file and directory ownerships change because someone edited the files as root. When you create home directories for new users, be sure to make the user the owner of the dot (.) file in the home directory. When users do not own "." they cannot create files in their own home directory.
Access problems can also arise when the group ownership changes or when a group of which a user is a member is deleted from the /etc/groups database.
· How to Change File Ownership

Note - You must own a file or directory (or have root permission) to be able to change its owner.

  1. Type ls -l filename and press Return.

    The owner of the file is displayed in the third column.

  2. Become superuser.

  3. Type chown new-owner filename and press Return. Ownership is assigned to the new owner you specify.


  venus% ls -l quest  
  -rw-r--r--  1 fred   staff    6023 Aug  5 12:06 quest  
  venus% su  
  Password:  
  # chown ignatz quest  
  # ls -l quest  
  -rw-r--r--  1 ignatz   staff    6023 Aug  5 12:06 quest  
  #  

· How to Change File Permissions
Table 11-1 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.
Table 11-1
ValueDescription
0No permissions
1Execute-only
2Write-only
3Write, execute
4Read-only
5Read, execute
6Read, write
7Read, write, execute
  1. Type ls -l filename and press Return.

    The long listing shows the current permissions for the file.

  2. Type chmod nnn filename and press Return.

    Permissions are changed using the numbers you specify.


Note - You can change permissions on groups of files or on all files in a directory using meta characters such as (*?) in place of file names or in combination with them.

This example shows changing the permissions of a file from 666 (read/write, read/write, read/write) to 644 (read/write, read-only, read-only).

  venus% ls -l quest  
  -rw-rw-rw-  1 ignatz   staff    6023 Aug  5 12:06 quest  
  venus% chmod 644 quest  
  venus% ls -l  
  -rw-r--r--  1 ignatz   staff    6023 Aug  5 12:06 quest  
  venus%  

· How to Change File Group Ownership
* 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 3138 Oct 31 14:49 junk  
  $ chgrp 10 junk  
  $ ls -lg junk  
  -rw-r--r-- 1 staff  3138 Oct 31 14:49 junk  
  $  

See User Accounts, Printers, and Mail Administration and Name Services Administration Guide for information about how to edit group accounts.

Recognizing Problems With Network Access

If users have problems using the rcp remote copy command to copy files over the network, the directories and files on the remote system may have restricted access by setting permissions. Another possible source of trouble is that the remote system and the local system are not configured to allow access.
See Security, Performance, and Accounting Administration and NFS Administration Guide for information about problems with network access and problems with accessing systems through autofs.