Understanding the location of linked directories

There is a subtle difference between a "normal" directory and a directory created with a symbolic link to another directory.

What happens if you do a cd (change directory) to this type of directory? You are placed in the directory that the symbolic link points to.

This can be confusing, especially if you have changed your shell prompt so that it displays the current working directory.

Look at this example:

   pwd
       (print the user's working directory)
   /usr/home/john/tmp
   ln -s $HOME/accounts/may fifth
       (use a symbolic link named fifth that points to
        the directory $HOME/accounts/may)
   ls
   fifth
   cd fifth
       (change directory to the new directory)
   pwd
       (print the working directory)
   /usr/home/john/accounts/may
       (the user is actually in the the directory that the
        linked directory points to)

When the user does a cd (change directory) to the symbolically linked directory may in their current working directory, they change to the directory that this link points to, the directory /usr/home/john/accounts/may.


[Home] [Search] [Index] This site maintained by unixhelp@hardrock.org