Removing linked directories that contain links

What happens if you remove a directory that is a symbolic link to another directory and in which you have created links to other files and/or directories?

Remember that the directory is just a linkname pointing to the "real" directory; so it is in this directory that the linknames of files and/or directories exist.

When you remove this type of directory, all that happens is that the linkname of the directory is removed. Any links you have made to the directory remain in the directory that this linkname pointed to.

Look at this example:

   pwd
       (print the user's working directory)
   /home/tom/reports
   ls ../tmp/drafts
       (list the contents of this directory)
   expenditure targets
   ln -s $HOME/tmp/drafts quarterly
       (use a symbolic link to make the directory)
   cd quarterly
       (change directory to this linkname)
   ln $HOME/accounts/expenses
       (link a file to this linkname)
   ls
       (list the contents of the linked directory)
       (the linked file is listed)
   expenditure expenses targets
   cd ..; rm quarterly
       (go to the parent directory and remove the linkname)
   ls ../tmp/drafts
       (list the directory the linkname pointed to)
   expenditure expenses targets
       (the linked file is still there)

[Home] [Search] [Index] This site maintained by webmaster@deslab.mit.edu