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

Navigating the Filesystem


Notes:

Path:

  1. An absolute path is the exact location of a file or directory starting from the root directory. For example:
                                                     
                           / 
               +-----+-----+------+-----+
              bin   etc   home   usr   var
                           |
                      +---------+
                     abc       xyz
                      |
                    notes
                                                     
    

    the absolute path to the notes directory is /home/abc/notes . An absolute path always starts with /
     

  2. A relative path gives the location of a file or directory relative to the current directory. If the working directory is /home, then:
  3. Some special symbols may be used in relative paths.
    . the current directory
    .. the parent directory
    ~ your own home directory
    If the working directory is /home/abc, then .. is a relative path to /home. 

Commands:

  1. pwd - This command prints the working directory. Use it to find out where you are in the directory tree.
     
  2. cd - This command changes to a specified directory (access to some directories may be denied).
    eg: cd /
    eg: cd /home/xyz
    eg: cd ..


Questions & Answers:

  1. Your home directory is /home/abc
    You enter the command: cd ~
    What is your current directory now?
     
    Answer: /home/abc (you have changed to your own home directory no matter where you were before)
     
  2. Your current directory is /home/lmn
    You enter the command: cd .
    What is your current directory now?
     
    Answer: /home/lmn (you have changed to the current directory; in other words, you have stayed in the same place)
     
  3. Your current directory is /home/lmn
    You enter the command: cd ..
    What is your current directory now?
     
    Answer: /home (you have changed to the parent of /home/lmn which is one level up in the directory tree)
     
  4. Your current directory is /home/lmn
    You enter the command: cd labs
    What is your current directory now?
     
    Answer: /home/lmn/labs
     
  5. Your current directory is /home/lmn
    You enter the command: cd /labs
    What is your current directory now?
     
    Answer: /home/lmn (/labs is an absolute path to a directory called labs immediately under the root directory. This directory does not exist so you stay in your current directory.)
     
  6. Your current directory is /usr
    You enter the command: cd /bin
    What is your current directory now?

    Answer: /bin  (not /usr/bin)
     
  7. Your current directory is /home/lmn
    You enter the command: cd ../..
    What is your current directory now?
     
    Answer: /
     
  8. Your current directory is /var/spool/mail.
    You enter the command: cd ..
    What is your current directory now?
     
    Answer: /var/spool
     
  9. Your current directory is /usr/local/bin/corel.
    You enter the command: cd ../../sbin
    What is your current directory now?
     
    Answer: /usr/local/sbin
     
  10. What command(s) give the absolute path to your own home directory?
     
    Answer: cd ; pwd
    cd without any parameters transfers to the home directory
    pwd displays the current directory
    Note: you can have multiple commands on 1 line; separate them with a semi-colon

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