Difference Between Similar Terms and Objects

Difference Between Soft Link and Hard Link in UNIX in OS

A link in UNIX based system is used to establish connection between a file and the actual data on the disk. It’s more like a pointer or a reference that points to another file or a directory, just like the concept of pointers in programming languages.

Let’s say a file has a very long name and for some reasons, it cannot be changed. In UNIX, we can refer to the file with a reference using a shorter name for ease of use. These references to the same file in UNIX are called links. Simply put, a link is a means to refer to the contents of a file.

There are two types of links used in UNIX: Soft Links and Hard Links. Both are used basically for the same purpose except the way they behave.


What is a Soft Link?

A Soft Link, or a symbolic pink, is a small pointer file that associates a filename with the pathname. It is nothing but is a shortcut to the original file, similar to the shortcut option in the Windows operating systems. It simply serves as a reference to another file or directory without the actual contents of the file making it easy for you to simply delete the soft links without even affecting the contents of the original file or directory.

In simple terms, a soft link is usually an alias for the original file which redirects to the target file or directory when accessed through the pathname specified in the soft link’s subject. Additionally, you can use soft links to link across the filesystem.


What is a Hard Link?

A Hard Link is simply a replica of the original file which serves as a reference or a pointer to the same file thus making it easy to access even of the original file is removed or moved from its original location. Unlike soft links, changes made to the hard linked files will have effect on other files and the hard link still works even if you delete the source file from the system.

Hard links share the same Inode value and unlike soft links, they point to the file location instead of the directory. It is usually used in the file systems that allow more than on hard link for the same file. Simply put, a hard link is just an additional name for an already existing file on UNIX based systems.


Difference between Soft Link and Hard Link in UNIX


A soft link, also termed as a symbolic link, is a special pointer that establishes links between files. It’s very similar to the shortcut feature available in the Windows operating systems. A soft link simply is a shortcut of a file that serves as a reference to another file or directory. A hard link is very different than a soft link. It serves as a reference or pointer to the original file meaning it is the exact mirror copy of the original file it is pointing to. Simply put, a hard link is just an additional name for an already existing file.


As a soft linked file contains a separate Inode value pointing to the original file, the link becomes inaccessible if the original file or directory is removed from the system. It is just a shortcut to a file so you can delete the soft links without actually affecting the original file or directory. Unlike soft links, hard links share the same Inode value as the original pointing to the same file location. Hard links are more flexible than soft links because you can access the file even if the original file is removed from the system.


To establish links between files in UNIX based system, you need to use the “In” command. A soft link refers to a symbolic path which indicates the location of the original file but not the contents. A soft link is created using a “In -s” command.

In -s <source_file> <myfile>

Here, you’d replace the ‘source_file’ with the original file for which you want to create a soft link and ‘myfile’ with the name of the soft link or symbolic link and the command In -s creates the soft link to a file name, both in the current directory.

On the other hand, “In” command is used to create a hard link. The In command is a standard UNIX command used to create a hard link to point to multiple files with the same name.

In <source> <linkname>


Unlike soft links which can be used to link both files and directories, hard links can only link files but not directories. The difference gives soft links certain qualities that hard links do not have, such as the ability to link across the filesystem. Creation and deletion of symbolic links won’t affect the original file. Hard links, on the other hand, cannot be used to link files outside the filesystem. Hard links share the same Inode value with actual file contents so removing any link won’t affect other links and it will still show the contents of the file.

Soft Link vs. Hard Link: Comparison Chart


Summary of Soft Link vs. Hard Link

In a nutshell, both soft links and hard links allow more than one file name to refer to the same file somewhere else, but the difference lies in the way they behave when the source link is removed from the system. A hard link takes less space than a soft link but any change made to the hard link will eventually reflect in the original file, whereas any changes to the soft link won’t have any effect on the original file. A soft link is like a shortcut feature of the Windows operating system used as an alias to refer to the original file or directory, whereas a hard link is like a replica of the original file that links two files in the same filesystem.

Sagar Khillar

Sagar Khillar is a prolific content/article/blog writer working as a Senior Content Developer/Writer in a reputed client services firm based in India. He has that urge to research on versatile topics and develop high-quality content to make it the best read. Thanks to his passion for writing, he has over 7 years of professional experience in writing and editing services across a wide variety of print and electronic platforms.

Outside his professional life, Sagar loves to connect with people from different cultures and origin. You can say he is curious by nature. He believes everyone is a learning experience and it brings a certain excitement, kind of a curiosity to keep going. It may feel silly at first, but it loosens you up after a while and makes it easier for you to start conversations with total strangers – that’s what he said."

Search DifferenceBetween.net :

Custom Search

Help us improve. Rate this post! 1 Star2 Stars3 Stars4 Stars5 Stars

Email This Post Email This Post : If you like this article or our site. Please spread the word. Share it with your friends/family.

1 Comment

  1. This text is worth everyone’s attention. Where can I find out more?

Leave a Response

Please note: comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

References :

[0]Sobell, Mark G., and Peter Seebach. A Practical Guide to UNIX for Mac OS X Users. New Jersey: Prentice Hall, 2005. Print

[1]Moritsugu, Steve, et al. Practical UNIX. Indianapolis: Que Publishing, 2000. Print

[2]Lasser, John. Think UNIX. Indianapolis: Que Publishing, 2000. Print

[3]Image credit: https://en.wikipedia.org/wiki/Hard_link#/media/File:Simplified_illustration_of_hard_links_on_typical_UN*X_filesystem.png

[4]Image credit: https://upload.wikimedia.org/wikipedia/commons/thumb/5/50/Unix_history-simple.png/640px-Unix_history-simple.png

Articles on DifferenceBetween.net are general information, and are not intended to substitute for professional advice. The information is "AS IS", "WITH ALL FAULTS". User assumes all risk of use, damage, or injury. You agree that we have no liability for any damages.

See more about : ,
Protected by Copyscape Plagiarism Finder