Many Windows users crossing the big divide find the lack of shortcuts in Linux disconcerting. The apparent inability to manage without these friendly little links is overwhelming, but at a very basic level shortcuts can be dangerous. Working as an administrator for many years, the sheer amount of backuped links I've come across is staggering. Entire papers, projects and databases lost in the blink of an eye... with only a MyFile.lnk for comfort... like a ghost from the past. Linux or more specifically Unix deals with shortcuts in a very different way... links. Using the ln command, links can be created and worked with very much in the same way as files. First off, let me draw the difference between hard links and symbolic (soft) links. Hard links are assigning a physical file an additional file name. These should not be considered shortcuts, because the original file and the newly created "link" are one and the same... they are on equal footing. Remember, "files" just point to an area of the disk where relevant data resides. In a sense they are just pointers... or markers.
Symbolic links (soft links) are more like shortcuts. Soft links simply point to a pre-existing file. If that file is deleted, the symbolic link becomes invalid. Conversely, only when the last hard link to a file is removed is the data actually removed from the drive. You can tell how many hard links a file has by pulling the inode value from an ls -l command:
-rw-r--r-- 4 cantin rcsg 78519 Aug 5 1992 bigcat.ps
(Here you can see that the file bigcat.ps has 4 hardlinks.)
Although hard links are preferable therefore, there are times when symbolic links must be used... when spanning different file systems for example. The big sell? The system transparently interprets soft links... so if I copy a symbolic link to my backup drive... the original file is backed up. Are all links created equal? Apparently not.

0 comments:
Post a Comment