link/symbolic link~ What is the difference?

Góra strony
Załączniki:
Wiadomość jako email
+ (text/plain)
Delete this message
Reply to this message
Autor: William Lindley
Data:  
Stare tematy: link/symbolic link~ What is the differance?
Nowe tematy: Renamed document file becomes a zip archive., Compiling kernel
Temat: link/symbolic link~ What is the difference?
Both types of link are quite unlike a copy.

    cp existing_file new_name


      creates a copy of existing_file called new_name.  The
      new file will have a unique inode, so changing the new
      file won't affect the old one, and vice versa.  NOTE: unlike
      DOS, unix "cp" by default stamps the new file with the current
      date and time; use "cp -p" to preserve the date and time.


    ln target_file new_name


      creates a directory entry called new_name which has the
      same inode (physical disk location) as the target_file.
      The target_file must be an existing file on the disk.
      Editing the file by either name changes them both.
      If you then delete (rm) one of them, the file contents
      stay on the disk... until you delete *all* of the inodes
      that point to it.


    ln -s target_file new_name


      creates a directory entry called new_name which is a
      reference (i.e., redirection) to the target_file.  The
      target_file need not even exist.  So "ln -s bar foo"
      just means that anytime you refer to "foo" it is the same
      as referring to "bar" ... if you delete the real file "bar"
      then "cat foo" will say "No such file or directory" even
      though the link "foo" exists (because "bar" doesn't).


\\/
http://www.wlindley.com