FLOPPIX Home | FAQ | Download | Labs | ToC | Back |  Next 

The search path


Notes:

  1. When you enter a command, the operating system has to search for that program. The path defines the directories which the system will search.
     
  2. To find out your current path, enter the command: echo $PATH
    The output may be: /usr/bin:/bin
    The path is a list of directories separated by colons.

    The path /usr/bin:/bin means that when you enter a command, the shell will search for the program in the directory /usr/bin and then in the directory /bin. If the program is stored in either of these 2 directories, it will run; if the program is not stored in either of these 2 directories, you will only get an error message.
     
  3. To change the path to /bin, use the command: PATH=/bin
    To add the directory /usr/local/bin to the existing path, use the command: PATH=$PATH:/usr/local/bin
     
  4. Note: the current directory is NOT automatically included in the search path. If there is an executable program called greatgame in the current directory, entering the command, "greatgame" results in the error message "command not found". You can see the file, but the shell cannot. To run the program, enter the command "./greatgame".
  5. Without a path, you would have to know where every program is stored on your system. To use the cal program, you would have to type /usr/bin/cal ; to use the date program, you would have to type /bin/date ; etc


Exercises:

  1. What is your current search path?  _________________________
     
  2. Change the path to include /usr/bin , /bin , /usr/sbin .
     
  3. Verify that the search path was changed by entering the command: echo $PATH
     
  4. Change your path so that it includes ONLY your home directory.
     
  5. Verify that the search path was changed.
     
  6. Try to get a directory listing - what happens? _________________________
     
  7. Now try to get a directory listing using the command: /bin/ls. Did this work? _____
     
  8. Logout and login again. What is your search path now?

Copyright © L.M.MacEwan
FLOPPIX Home | FAQ | Download | Labs | ToC | Back |  Next