homepage Welcome to WebmasterWorld Guest from 23.20.77.156
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
Hard link between files in linux
rajeshk98




msg:3120756
 5:32 am on Oct 14, 2006 (gmt 0)

What is the difference between ln -s and ln -S . both are used for hard linking of files or folders.

 

mcavic




msg:3121437
 10:02 pm on Oct 14, 2006 (gmt 0)

ln is used for hard linking
ln -s is used for symbolic linking

As for the -S, it's an option to be used when making automatic backups of the destination file, which I've never done.

jtara




msg:3121567
 2:01 am on Oct 15, 2006 (gmt 0)

You've got the terminology a bit backwards.

ln -s is used to create symbolic links. Just plain ln creates "hard links". Some people refer to symbolic links as "soft links".

A hard link is simply an additional directory entry pointing to the same data. They're a bit of a pain from a bookkeeping perspective, as it's impossible to easily determine where they point. You can only tell how MANY of them there are pointing to the same data. But they're a bit faster than symbolic links. And when you delete a file via a hard link, the file and all the links go away. Not so with a symbolic link.

The -S option, as pointed-out above, has nothing to do with hard or soft links. It deals with adding a suffix to backup files.

mcavic




msg:3121690
 6:31 am on Oct 15, 2006 (gmt 0)

when you delete a file via a hard link, the file and all the links go away. Not so with a symbolic link.

Not quite. If you hard-link file A to file B, you can delete either one and the other will still be there intact.

But with symbolic links, if you delete the file itself, the link becomes useless.

Also, hard links work only between files on the same filesystem, and not directories. Symbolic links will work across filesystems, and directories too.

jtara




msg:3121694
 7:01 am on Oct 15, 2006 (gmt 0)

Not quite. If you hard-link file A to file B, you can delete either one and the other will still be there intact

Sorry... correct. The file will disappear when you have removed all of the hard links (including the original).

There's no difference between a normal directory entry and a hard link. A hard link is simply a duplicate directory entry.

BTW, Windows supports symbolic links, though it's an obscure, poorly-documented feature that has some quirks.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved