What is Hard link and Soft link in Linux – Explained

What is Hard link and Soft link

You may hard some questions are repeated always, in that hard link and soft link has good repeats, also It’s always confuses us sometimes. Here is our some answer about hard and soft links to impress your interviewer.

What is a Soft Link or Symbolic Link or Symlink?

Symbolic links or Symlinks are the easiest to understand, because for sure you have used them, at least when you were using Windows. Soft links are very similar to what we say “Shortcut” in windows, is a way to link to a file or directory. Symlinks doesn’t contain any information about the destination file or contents of the file, instead of that; it simply contains the pointer to the location of the destination file. In more technical words, in soft link, a new file is created with a new inode, which have the pointer to the inode location of the original file. This can be better explained with a diagram:

Symbolic links are created with the “ln” command in linux. The syntax of the command is:

# ln -s
-s = This flag tells to create a symlink (if you don’t use this it will create a hard link, which we will talk about soon).

For Example, if you want to create a soft link of one of your favorite application, like gedit, on your desktop, use the command like this:

# ln -s /usr/bin/gedit ~/Desktop/gedit

I hope now the concept of Soft Links should be clear.

What is a Hard Link?

Hard link is a bit different object when compared to a symlink. In softlink a new file and a new Inode is created, but in hard link, only an entry into directory structure is created for the file, but it points to the inode location of the original file. Which means there is no new inode creation in the hard link? This can be explained like this:

So, in hard link, you are referencing the inode directly on the disk, which means that there should be a way to know how many hard links exist to a file. For the same, in the inode information, you have an option for “links”, which will tell how many links exists to a file. You can find the same information by using this command:

# stat <file name>

# stat 01
Size: 923383 Blocks: 1816 IO Block: 4096 regular file
Device: 803h/2051d Inode: 12684895 Links: 3
Access: (0644/-rw-r–r–) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2012-09-07 01:46:54.000000000 -0500
Modify: 2012-04-27 06:22:02.000000000 -0500
Change: 2012-04-27 06:22:02.000000000 -0500

In this example, it means that the specific file have 2 hard links, which makes the count to 3.

You can create a hard link with the same command “ln” like this

# ln

So, to create a hard link of gedit program on your desktop, you will use the command like this:

# ln /usr/bin/gedit ~/Desktop/gedit

Now, the bigger question is, who will decide what is better and when to use soft link or hard link

When to use Soft Link:

  1. Link across file systems: If you want to link files across the file systems, you can only use symlinks/soft links.
  2. Links to directory: If you want to link directories, then you must be using Soft links, as you can’t create a hard link to a directory.

When to use Hard Link:

  1. Storage Space: Hard links takes very negligible amount of space, as there are no new inodes created while creating hard links. In soft links we create a file which consumes space (usually 4KB, depending upon the filesystem)
  2. Performance: Performance will be slightly better while accessing a hard link, as you are directly accessing the disk pointer instead of going through another file.
  3. Moving file location: If you move the source file to some other location on the same filesystem, the hard link will still work, but soft link will fail.
  4. Redundancy: If you want to make sure safety of your data, you should be using hard link, as in hard link, the data is safe, until all the links to the files are deleted, instead of that in soft link, you will lose the data if the master instance of the file is deleted.

The above points gives you a small idea where to use what, but doesn’t tell you that those are the only options. Everything depends on your setup.

How file is deleted having hard links:

So, as it’s pretty clear from the above article that hard links are just the reference to the main file location, and even if you delete one link, the data will still be intact. So, to remove a hard link, you need to remove all the links, which are referring to the file. Once the “link count” goes to “0”, then the inode is removed by the filesystem, and file is deleted.


Q. What is the one line answer to the question “What is the main difference between hard links & soft links”?

A. A softlink will have a different Inode number than the source file, which will be having a pointer to the source file but hardlink will be using the same Inode number as the source file.

Q. How can I find all the Soft Links in my system?

A. Use this command for the same “find /etc -type l -exec ls -li {} \;”

Q. How can I find all the files having Hard Links in my system?

A. Use this command for the same “find / -links +2 -type f -exec ls -li {} \;”

How to find whether a file is a softlink?

Simply using this command “ls -l” will tell you whether a file is pointing to some other file or not.

Q. How to check whether a file have any softlink pointing to it?

A. Till now, I am not aware of any way to do that. If I will find any, I will surely update my post.

Q. How can I find out the source file of a hard link?

A. No, you can’t find out the source file of a hard link. Once hard link is created, there is no way to tell which the first file was created.

Q. Can I make a Soft link to a hard link and Vice Versa?

A. Yes, both soft links and hard links acts as normal files of the file system, so you can do both.


  1. Howdy, i read your blog sometimes and i own an identical one and i was simply wondering in the event you get a variety of spam comments? If so how do you stop it, any plugin or something you can advise? I get so much recently it is driving me mad so any help is very a lot appreciated. Anyway, in my language, there are usually not a lot good supply like this.
    cole haan store online http://www.colehaanstore.online

  2. Today, I went to the beach with my kids. I found a sea shell
    and gave it to my 4 year old daughter and said
    “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed.
    There was a hermit crab inside and it pinched
    her ear. She never wants to go back! LoL I know this is totally off topic
    but I had to tell someone!

  3. He ist dieses ein großer Pfosten. Kann ich einen Teil auf ihm auf meinem Aufstellungsort benutzen? Ich würde selbstverständlich mit Ihrem Aufstellungsort verbinden, also konnten Leute den vollen Artikel lesen, wenn sie zu wünschten. Dankt jeder Weise.
    mcm backpack sale http://www.mcmsale.shop

  4. Hey I know this is off topic but I was wondering if you knew of
    any widgets I could add to my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would
    have some experience with something like this. Please let me know if you run into anything.

    I truly enjoy reading your blog and I look forward to your new updates.

  5. I cnduot bvleiee taht I culod aulaclty uesdtannrd waht I was rdnaieg. Unisg the icndeblire pweor of the hmuan mnid, aocdcrnig to rseecrah at Cmabrigde Uinervtisy, it dsenot mttaer in waht oderr the lterets in a wrod are, the olny irpoamtnt tihng is taht the frsit and lsat ltteer be in the rhgit pclae. The rset can be a taotl mses and you can sitll raed it whoutit a pboerlm. Tihs is bucseae the huamn mnid deos not raed ervey ltteer by istlef, but the wrod as a wlohe. Aaznmig, huh? Yaeh and I awlyas tghhuot slelinpg was ipmorantt! See if yuor fdreins can raed tihs too.
    cheap marmot online http://www.marmotshop.online

  6. Yesterday, while I was at work, my sister stole my
    apple ipad and tested to see if it can survive a forty foot drop, just so she can be a youtube sensation. My iPad is now destroyed and she has 83 views.
    I know this is totally off topic but I had to share it
    with someone!

  7. I do trust all the ideas you have offered for your post.
    They are really convincing and will definitely work. Still, the posts are very quick for beginners.
    May just you please extend them a bit from next time? Thank
    you for the post.

  8. How can i extend the range of a Wireless N router? I have an Xtreme N handheld router (Dlink). I have to extend the reach in the wireless signal. I know how to do it for the G signal. I want to know how to do the idea for an N sign. Is it possible make use of regular N routers as repeaters. If so, how to configure them. Thanks for that information.
    patagonia nano puff jacket sale http://www.unilorites.com/patagonia/

  9. With havin so much content and articles do you ever run into any issues of
    plagorism or copyright violation? My website has a lot of
    unique content I’ve either written myself or outsourced but it looks like a lot of it
    is popping it up all over the internet without my authorization. Do you know any ways to help reduce content from being ripped off?
    I’d certainly appreciate it.

  10. I just couldn’t leave your website prior to suggesting that I really enjoyed the standard information a
    person supply on your guests? Is going to be again regularly in order to check out new

  11. Pricey Blog holder. My husband and i love this posting along with your current site overall! The genuine piece of content is generally especially undoubtedly published along with effortlessly acceptable. Your current WP layout is without a doubt remarkable on top of that! Is going to be awesome to know just where My partner and i can acquire the fact that. Be sure to support furthermore , firm abs fine work. Everyone involve a lot more a lot of these webmasters which includes yourself on the net and much less spammers. Excellent partner!
    Jack Wolfskin Jackets Outlet http://www.jackwolfskinoutlet.online

  12. This particular supplement ended up being with that great rate I do not thought that top quality would be so exceptional. It’s beautiful. This one mother is going to adore that in Holiday morning when she opens gift and it appearances like I spent alot more, then again prices had been simply awesome!!

  13. Took me time to learn all of the comments, however I actually enjoyed the article. It proved to be very helpful to me and Im certain to all of the commenters right here! It is all the time nice when you cant only be informed, but in addition engaged! Im positive you had joy writing this article. Anyway, in my language, there will not be much good source like this.
    patagonia store online http://www.newfashion.store

  14. I’m curious to find out what blog platform you have been working with?

    I’m experiencing some small security problems with my latest site and I would like
    to find something more risk-free. Do you have any solutions?

  15. Hey I know this is off topic but I was wondering if you knew of any widgets I could add to
    my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite
    some time and was hoping maybe you would have some experience with
    something like this. Please let me know if you run into anything.

    I truly enjoy reading your blog and I look forward to your new updates.

  16. We have a strict coverage of by no means even glancing at a guide till
    something goes improper, but given our relative inexperience with laptop
    shoes we decided to make an exception this time

  17. Almost 40 of a strong population are affected by tinnitus. For around one on 100, it have been a strong very serious long-term problem. Most people at permanent tinnitus learn t cope by using my own problem. For some people, tinnitustinnitustinnitus perform lead capital t problems such as depression plus sleep disorders.
    factory adidas outlet http://www.cheapadidas.online

  18. You ought to actually think about engaged on creating this blog into a significant authority on this market. You evidently have a grasp handle of the topics everyone seems to be trying to find on this website in any case and you could actually even earn a buck or two off of some advertisements. Id discover following latest subjects and raising the quantity of write ups you place up and I guarantee you’d begin seeing some amazing targeted traffic within the close to future. Only a thought, good luck in no matter you do!
    ugg boots sale http://www.uggsale.online

  19. This was a actually incredibly beneficial submit. In theory I’d prefer to create like this also – getting time and actual effort to make a excellent piece of writing but what can I say I procrastinate alot and by no means appear to obtain a thing done.
    mk outlet store http://www.apcsale.co.uk

  20. Unfortunately all of these goods have both fake and
    genuine licensed goods available so use caution that you decide to purchase products.
    Haye amazingly is making his 5th fight like a heavyweight after moving up from cruiserweight, yet he is still the heavyweight fighter whose name is on everybody’s lips at the moment.
    The biggest advantage could be the store employees find added time for your customer (that’s actually their core job), instead of spend time on inventory, searching, recording tracking, etc.

  21. Hi every one, here every person is sharing these kinds of know-how, so it’s pleasant to
    read this webpage, and I used to visit this webpage every day.

  22. Ive to say, I dont know if its the clashing colors or the unhealthy grammar, but this weblog is hideous! I imply, I dont want to sound like a know-it-all or anything, however may youve probably put slightly bit extra effort into this subject. Its really attention-grabbing, but you dont symbolize it well in any respect, man. Anyway, in my language, there arent much good source like this.
    cheap cole haan http://www.colehaan.online

  23. Fact be instructed, there are a variety proposed solutions out there assist you stop snoring. Some have more potential than others but actually it is dependent upon you, and just how unhealthy your evening breathing problem is. We now have uncovered alternative routes to cease loud night from as far out as hypnosis to loopy concoctions of ingredients in tea. That mentioned, the the following different snoring cures usually tend profit the typical snorer.
    ecco outlet coupon http://www.matchesvogue.co.uk

  24. I found your site from wikipedia and read a few of your other blog posts.They are cool. Pls continue this great work. Later on other fantastic American rock acts such as Lynrd Skynrd, The Eagles, America, the Allman Brothers, and the Doobie Brothers would come on the scene and shake up the world with their string of hit songs.
    cheap Rene Caovilla http://www.renecaovilla.online

  25. Hello There. I found your blog using msn. This is a really
    well written article. I will make sure to bookmark it and come back to
    read more of your useful info. Thanks for the post.

    I will certainly return.

  26. It device was at that ideal price I not considered that the high quality would be and so excellent. It is pretty. It mama can prefer that it concerning Christmas day when she opens present and it looks as though I devoted a lot more, but rates had been only ideal!!

  27. Just a fast hello and also to thank you for discussing your ideas on this web page. I wound up inside your weblog right after researching physical fitness connected issues on Yahoo guess I lost track of what I had been performing! Anyway I’ll be back once again inside the potential to check out your blogposts down the road. Thanks!
    factory ecco outlet online http://www.ewardrobe.co.uk

  28. Its in reality a huge post. I am sure that anyone would like to visit it again and again. After reading this post I got some very unique information which are in actual fact very helpful for anyone. This is a post experiencing some crucial information. I wish that in future such posting should go on.
    cole haan outlet online http://www.colehaanoutlet.online

  29. I was wondering if you ever considered changing the page layout of
    your blog? Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content so people could connect with
    it better. Youve got an awful lot of text for only having 1
    or 2 images. Maybe you could space it out better?

  30. I guess you have made many really interesting points. Not as well many ppl would actually think about it the direction you just did. I am really impressed that there is so much about this subject that has been uncovered and you made it so nicely, with so considerably class. Top-notch one, man! Very special things right here.
    moncler gamme bleu online http://www.moncleroutletonlineu.us

  31. I have purchased this one brand name concerning bracelet various occasions. Every a person is very adorable, has made well, does not tarnish furthermore important based on which a person you purchase plus who your give that in order to.

  32. Can I just say what a relief to discover a person that genuinely knows
    what they’re talking about on the net. You definitely realize how to bring
    an issue to light and make it important. A lot more people need to read
    this and understand this side of the story. I was surprised you’re not more popular because you certainly possess the gift.

  33. Effectiveⅼy likе Mommy mentioned, օnce we lօve each
    other and love the ᴡorld tjat Jesuѕ died for, that?s a sort of worship.
    When ᴡe take into consideration God and take heed to the semon orr in Sunbday Faculty, that?ѕ a manner of worsһipping as a result
    of were learning h᧐w niϲe God is and Hе liҝes tһat.
    Or after we sit around andd tell each other whzt the
    greatest things about God are. You understand how muϲh you want hearin pеople say how good or
    cute you boys are? Well God likes after we speak collectively about how nice he is.?
    Daddy answered.

  34. What’s up to all, the contents existing at this web page are in fact remarkable
    for people knowledge, well, keep up the good work fellows.

  35. hi!,I love your writing so much! share we keep in touch more about your article on AOL?

    I require a specialist in this space to resolve my problem.
    May be that’s you! Looking ahead to see you.

  36. Nicelү boys,? Mommy finally mentioned after that they had gige you plenty of foolish
    ideas of what God did for fun, ?What God actually likes is wɡen olks love each other
    and care foг ߋne another like we do in οour family.?
    That made sense to Lee and Larry sso Lee hugged Mommү and Larry hugged daddy to just make God happy.

  37. Can I just say what a comfort to discover an individual who truly understands what they’re talking about over the internet.
    You definitely know how to bring an issue to light and
    make it important. A lot more people should read this and understand this side of the story.
    I was surprised that you’re not more popular given that you certainly possess the gift.

  38. Hi I am so delighted I found your site, I really found you by mistake, while I was researching on Bing for something else, Nonetheless I am
    here now and would just like to say kudos for a incredible post and
    a all round thrilling blog (I also love the theme/design), I don’t have time to browse
    it all at the minute but I have book-marked it and also added your RSS feeds, so when I have time I will be back
    to read much more, Please do keep up the awesome job.

  39. Singing worѕhip songs is good but that?s not the only option to
    worship.? Daddy said, maybe to make Larry ѕtop singing. ?There aare many ways to worsһіp.

  40. I do agree with all off the concepts you’ve presented to
    your post. They are reeally convincing and
    will definitely work. Nonetheless, the posts aree very brief for newbies.
    May you please lengthen them a littfle from next time?
    Thank you for thee post.

  41. I am really enjoying the theme/design of your weblog.

    Do you ever run into any web browser compatibility issues?
    A small number of my blog audience have complained about my blog not working correctly in Explorer but looks great in Safari.
    Do you have any ideas to help fix this problem?

  42. Hey there! Do you use Twitter? I’d like to follow you if that would be ok.
    I’m definitely enjoying your blog and look forward to new updates.

  43. Howdy! I know this is somewhat off topic but I was wondering if you knew
    where I could find a captcha plugin for my comment form?
    I’m using the same blog platform as yours and I’m having trouble finding one?

    Thanks a lot!

  44. I knoᴡ!? Mentioned Larry. ?I wager he ⅼіkes angels
    as a resuⅼt of he has them round all tһe time. Maybe he
    and the angels play family games like we do sometimes.
    Possibly they play Monopoly.? This made Mommy chucҝle reallly