System Administration Guide

Chapter 71 Troubleshooting File Access Problems

This is a list of the step-by-step instructions in this chapter.

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 could previously use. Whenever you encounter such a problem, investigate one of three areas:

This chapter briefly describes how to recognize problems in each of these three areas and suggests possible solutions.

Solving Problems With Search Paths (Command not found)

A message of Command not found indicates one of the following:

To fix a search path problem, you need to know the pathname of the directory where the command is stored.

If the wrong version of the command is found, a directory that has 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.

You can display your current search path by using the echo $PATH command.


$ echo $PATH 
/home/kryten/bin:/sbin:/usr/sbin:/usr/openwin/bin:/usr/openwin/bin/xview:
/usr/dist/local/exe:/usr/dist/exe

Use the which command to determine whether you are running the wrong version of the command.


$ which maker 
/usr/doctools/frame5.1/bin/maker

Note -

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


How to Diagnose and Correct Search Path Problems

  1. Display the current search path to verify that the directory for the command is not in your path or that it isn't mispelled.


    $ echo $PATH 
    
  2. Check the following:

    • Is the search path correct?

    • Is the search path listed before other search paths where another version of the command is found?

    • Is the command in one of the search paths?

    If the path needs correction, go to step 3. Otherwise, go to step 4.

  3. Add the path to the appropriate file, as shown in this table.

    Shell 

    File 

    Syntax 

    Notes 

    Bourne and Korn 

    $HOME/.profile

    $ PATH=$HOME/bin:/sbin:/usr/local
    /bin ...
    
    $ export PATH
    

    A colon separates path names. 

    $HOME/.cshrc

    or 

    $HOME/.login

    $ set path=(~bin /sbin /usr/local/
    bin ...)
    

    A blank space separates path names. 

  4. Activate the new path as follows:

    Shell 

    File Where Path Is Located 

    Activate The Path With ... 

    Bourne and Korn 

    .profile

    $ . ./.profile
    

    .cshrc

    hostname% source .cshrc
    

     

    .login

    hostname% source .login

  5. Verify the path using the command shown below.


    $ which command
    

Example--Diagnosing and Correcting Search Path Problems

This example shows that the OpenWindows executable is not in any of the directories in the search path using the which command.


venus% openwin
Command not found
venus% echo $PATH
no openwin in . /home/ignatz /sbin /usr/sbin /usr/bin /etc 
/home/ignatz/bin /bin /home/bin /usr/etc
venus% vi ~.cshrc
(Add appropriate command directory to the search path)
venus% source .cshrc
venus% openwin

If you cannot find a command, look at the man page for its directory path. For example, if you cannot find the lpsched command (the lp printer daemon), lpsched(1M) tells you the path is /usr/lib/lp/lpsched.

Solving File Access Problems

When users cannot access files or directories that they previously could access, the permissions or ownership of the files or directories probably has changed.

Changing File Permissions

Table 71-1 shows the octal values for setting file and directory permissions. You use these numbers in sets of three to set permissions for owner, group, and other (in that order). For example, the value 644 sets read/write permissions for owner, and read-only permissions for group and other.

Table 71-1 Octal Values for File Permissions

Value 

Description 

No permissions 

Execute-only 

Write-only 

Write, execute 

Read-only 

Read, execute 

Read, write 

Read, write, execute 

Changing File and Group Ownerships

Frequently, file and directory ownerships change because someone edited the files as superuser. 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/group database.

Use the chown command to change file ownership.


# chown new-owner filename

new-owner

Is the specified user-name or UID of the new file owner. There must be an entry for the specified user-name in the passwd file.

filename

Is the specified file or directory. 

Use the chgrp command to change group ownership.


# chgrp new-owner filename

new-owner

Is the specified group ID or GID of the new group owner. There must be an entry for the specified group-name in the group file.

filename

Is the specified file or directory. 

How to Change File Permissions

  1. List the file permissions.


    # ls -l filename
    

    -l

    Displays the long listing, which includes current permissions for the file. 

    filename

    Is the specified file or directory. 

  2. Change the file permissions.


    # chmod nnn filename
    

    nnn

    Are numbers representing the permissions you are assigning to the file owner, the group owner, and all others, in that order. 

    filename

    Is the specified file or directory. 

    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.


  3. Verify that the permissions have been changed by using the ls -l command.


    $ ls -l filename
    

    The long listing shows the current permissions for the file.

Example--Changing File Permissions

This example shows changing the permissions of a public directory from 744 (read/write/execute, read-only, and read-only) to 755 (read/write/execute, read/execute, and read/execute).


$ ls -ld public_dir
drwxr--r--  1 ignatz   staff    6023 Aug  5 12:06 public_dir
$ chmod 755 public_dir
$ ls -ld public_dir
drwxr-xr-x  1 ignatz   staff    6023 Aug  5 12:06 public_dir

This example show changing the permissions of an executable shell script from read/write to read/write/execute.


$ ls -l my_script
-rw------- 1 ignatz   staff    6023 Aug  5 12:06 my_script
$ chmod 700 my_script
$ ls -l my_script
-rwx------ 1 ignatz   staff    6023 Aug  5 12:06 my_script

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. Become superuser.

  2. List the file permissions.


    # ls -l filename
    

    -l

    Displays the long listing, which includes the owner of the file, displayed in the third column. 

    filename

    Is the specified file or directory. 

  3. Change the file owner.


    # chown new-owner filename
    

    Ownership is assigned to the new owner you specify.

  4. Verify the file ownership change.


    # ls -l filename
    

Example--Changing File Ownership


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

How to Change Group Ownership

  1. List the file permissions.


    # ls -l filename
    
  2. Change the group that owns the file or directory.


    $ chgrp GID filename
    

    The group ID for the file or directory you specify is changed.

  3. Verify the file ownership change.


    # ls -l filename
    

Example--Changing Group Ownership


$ ls -l junk
-rw-r--r-- 1 kryten other 3138 Oct 31 14:49 junk
$ chgrp staff junk
$ ls -l junk
-rw-r--r-- 1 kryten staff 3138 Oct 31 14:49 junk

See Chapter 51, Securing Files (Tasks) 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 NFS Administration Guide for information about problems with network access and problems with accessing systems through AutoFS.