Hard Link vs Symbolic Link

Hard Link vs Symbolic Link

Similarities, differences, advantages and disadvantages between the two for Linux Operating System.

What is a link?

In the most generic sense a link is connection between two objects. More specifically in computing; according to the Oxford Definition a link is a connection to a code or instruction which connects one part of a program or an element in a list to another. In this case, it is a connection from file or directory that is in one location, and be able to access it from another location. To do this, a link-file must be created from an original-file The rest of this blog is about the comparison of two ways to create the link-file which is by a hard link or a symbolic (soft) link.

Similarities and Differences:

For start, they both are a ways to reference an original file from another location, and they both actually access the original file, fulfilling the purpose of a link. Also, nothing will happen to the original file if the link-file is moved, renamed, or deleted.

The main difference is that one points to the physical location of the file in the hard drive and the other is a shortcut, a copy of the files current directory path. This will unleash the main advantages and disadvantages of both as it will be explained.

Difference between soft and hard links

Hard Link

What is a Hard Link?

The first way is with a Hard Link. This way of making a connection is through what is called the indode, which is in essence is the reference to the physical location of the file. This means that the link-file has the same indode value as the original-file, making it a sort of "moving copy of the original-file".

Properties:

The properties of the hard link are that the link-file has the same size as the original file since it is a reference to the same location of the original file therefore not only a reference to it but also the same properties.

Advantages:

Since it is a reference to the file's physical location and not just to its current location, the link will remain available and will not be affected even if the original file is moved, renamed or deleted. In other words, if any of this things occur, the link-file will still access the information in the original file. The link-file will still work.

Disadvantages:

Hard Link's main disadvantage is it can not be created for a directory nor it can be created for files on different file systems.

Command:

$ ln [original filename] [link name]

Symbolic Links

What is a Symbolic Link:

A symbolic or soft link is a string which is the pathname of the original file, in other words, a shortcut as we know it in Windows Operating System. This kind of link references virtual or path location of the original file but not the physical location.

Properties

The filename in the soft link is in essence the pathname to the original file, therefore the size of this link is only the length name of the file link. It is not the size of the original file.

Advantages:

The main advantage, as we just saw, is that it will not take much space since its size will be smaller.

Another advantage is that it can be created for directories and for different file systems.

Disadvantages:

Some real big disadvantages are that if the file is renamed, moved or deleted the link-file will become useless becoming a hanging link.

Command:

$ ln -s [original filename] [link name]

For further reading please vistit this websites




要查看或添加评论,请登录

Mateo Garcia的更多文章

  • Go Deeper!

    Go Deeper!

    In this article, the beauty and power of recursion will be exposed and explained. The idea is to explain this concept…

  • Everything is an Object!

    Everything is an Object!

    In this article, a simple explanation of Python's Objects will be given! It's been said that in Python everything is an…

  • Compilation Process in C Explained

    Compilation Process in C Explained

    Explaining the overall process Intro C programming language is one of those that needs to be "compiled" but what does…

社区洞察

其他会员也浏览了