Hard and Soft Links

  • Hard link/link: A filename in a directory is called a file hard link.  The same file may have several links in the same directory/different ones (kinda like persistent shortcuts)
$ ln p1 p2
  • Creates a new hard link with pathname “p2” for a file identified by “p1”
  • Hard links cannot be for directories
  • Hard links only exist for files in the same filesystem (eg. NTFS<->FAT32)

 

  • Soft/Symbolic Link: Short files that contain arbitrary pathname of another file.  Destination may be in any other system.  (just a regular shortcut)
$ ln -s p1 p2
  • Creates a new soft link with pathname p2 refering to p1

enter image description here

my-hard-link persists after moving myfile.txt while my-soft-link will be a broken shortcut

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s