how are hard links different from symbolic links? what advantages do symbolic links have over hard links?

3 Answers

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    A hard link is a point in a directory structure that points directly to a particular file's contents. Every file in a system has at least one, but you can add more where you need them.

    A symbolic link is a special file that, instead of pointing directly to the file it's referencing, tells the OS where to find it.

    Symbolic links can do 2 things that hard links generally can't...

    - Link to files across file systems (due to the fact that it's an indirect link)

    - Link to directories

  • 1 decade ago

    A Hard Link is where a file has two names which are both on an equal weighting, and both of the file names in the "inode table" point directly to the blocks on the disc that contain the data. See diagram to the left.

    You set up a hard link with an ln command without options - if the file ab.txt already exists and you want to give an additional name (hard link) to it, you'll write

    ln ab.txt cd.txt

    and then both names will have equal ranking. The only way you'll know that there's a link there is by doing a long listing and you'll see a link count of 2 rather than 1, and if you need to find out what's linked to what, use the -i option to ls.

    A Symbolic Link is where a file has one main name, but there's an extra entry in the file name table that refers any accesses back to the main name. This is slighly slower at runtime that a hard link, but it's more flexible and much more often used in day to day admin work.

    Symbolic links are set up using the ln command with the -s option - so for example

    ln -s ab.txt cd.txt

    will set up a new name cd.txt that points to the (existing) file ab.txt. If you do a log listing (ls -l) of a directory that contains a symbolic link, you'll be told that it's a symbolic link with an "l" in the first column, and you'll be told where the file links to in the file name column. Very easy to spot!

  • Anonymous
    5 years ago

    Soul's Urge: 6 Personality: 3 Quiescent Self: 3 Destiny: 9 Lifepath: 5 This Year's Path: 7 Next Year's Path: 8

Still have questions? Get your answers by asking now.