MicroNuggets: Hard Links versus Soft Links Explained

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024

Комментарии • 110

  • @jvsnyc
    @jvsnyc 5 лет назад +79

    This is a better explanation than most on RUclips, but the size shown in ls is misleading! If I have a 60GB file with 20 hard links to it, it still takes up just 60GB, not 60GB * 20. ls dash l will show the original full 60GB size for each place that a hard link exists, which is confusing/wrong. In some quick experiments it appears that du only counts each hardlink'ed file once, not per each hardlink.
    A soft link doesn't save space. There are still at least two reasons you would prefer them. They can point to directories as well as to plain files. Also, they can point to anything that can be expressed under root ( "/" ) i.e. anything you can type. Hard-links can only point to something within the same partition/volume/mount point, because they specify the inode # which is specific to a given partition, volume or mount point. This advantage goes away if you know for an absolute fact everything is on the same big partition, but you need to be careful if there are multiple mounts/partitions.
    Hard-links can't break by someone removing a file that they don't realize you have soft-linked to. Also, when you do an ls on them one of the things it shows you is the reference count, which is not affected by soft links, so just seeing a reference count of 1 doesn't mean it is safe to remove a file, there could be any number of soft-links to that file or directory which will break the minute you remove it. Unix and Linux are still wonderful and awesome, but many people are confused about these points and you do need to be careful about this.

  • @aayyaa1188
    @aayyaa1188 3 года назад +50

    This is the best explanation I've found on RUclips. Thank you sooooo much for making the concept of soft link and hard link so clear.

  • @mattr7229
    @mattr7229 Год назад +1

    This is an awesome explanation. No editorializing, just what I need know explained in a short, easy to understand, and concise manner. Thank you.

  • @andrewjoe1836
    @andrewjoe1836 2 года назад +2

    This is the absolute best explanation I found yet and it was under 10 minutes long and I feel like I know what I need to understand the concept very well.

  • @ransazz
    @ransazz Год назад +1

    So basically, they're shortcuts! I'd imagine soft links are more similar to Windows shortcuts because if u delete the original file in Windows, the shortcut no longer functions despite being there (and also takes up very little space). I had trouble making the connection because hard and soft links seemed a bit abstract to me before I understood that. Thanks for the video!

  • @annexgroup6878
    @annexgroup6878 2 года назад +2

    Im so glad you use visuals. Thank you so much for explaining this.

  • @beto.aveiga
    @beto.aveiga 2 года назад +5

    Great explanation. The only thing missing would be practical examples on when to implement one or the other.
    I mean, real-life scenarios where you would prefer a soft link vs. a hard link, or vice-versa.

    • @codygosney976
      @codygosney976 Год назад

      Agreed, do you have an example of practical usage for these two concepts?

    • @JpsBookOfLife
      @JpsBookOfLife Год назад +2

      Hard Link -Space saving and data consistency: Suppose you have a large data file that needs to be accessed from multiple locations or by different users, but you don't want to consume extra disk space by creating copies. Hard links can be a good option here, as they will allow you to access the file from different locations without duplicating the file content. Plus, any modifications to the file content will be consistent across all hard links, since they all point to the same data.
      Backup purposes: Hard links can be used in some backup strategies. If you make a backup of a file by creating a hard link, and later make changes to the original file, the backup will still contain the original data. This can be handy for creating "snapshots" of files or directories at different points in time.
      Symbolic Link (Soft Link) -Linking directories: Only symbolic links can be used to link directories. So, for instance, if you're organizing your music files and want to have the same directory appear under multiple genres, you could use symbolic links to achieve this.
      Cross filesystem linking: If you need to create a link to a file or directory that resides on a different filesystem or partition, you'll need to use a symbolic link.
      Versioning systems: Soft links are often used in versioning systems. For example, in a situation where you have different versions of an application, you can create a symbolic link named "current" that points to the directory of the version currently in use. When you want to switch to a different version, you just need to change the symbolic link to point to a different directory.
      Broken Link Situations: There are cases where you might want a link to survive the removal of the original file. With a symbolic link, the link will remain (but will point to a non-existing file), and you can replace the original file later without needing to update the link.

  • @quinton6463
    @quinton6463 9 месяцев назад

    This is a fantastic video. I feel like a have a firm grasp on the concept after following along, all in under 10 minutes. Thank you!

  • @antosolisr
    @antosolisr Год назад

    gracias, es mil veces mejor su explicacion de menos de 10 minutos que horas de clase en mi universidad: UNLAM.

  • @Devildoc512
    @Devildoc512 7 месяцев назад +1

    wow, that was a perfect presentation!

  • @Mark-nm9sm
    @Mark-nm9sm 11 месяцев назад

    best explanation hands down. Thank you

  • @RockTheCage55
    @RockTheCage55 9 месяцев назад

    like others have said definitely the best explanation on youtube. Maybe i'm wrong but when deciding to use a hard or soft links i would think you would want to use hard links when you want to avoid broken links & don't want the data to deleted until the last use. I would think hard links would be more useful in most cases. Thanks for the great explanation

  • @memedaddyz
    @memedaddyz 2 года назад

    man this is the best explanation i've encountered so far omg

  • @bouhannacheabdallah
    @bouhannacheabdallah 4 года назад

    Among so many videos u r the first. One that gave the correct way of explanation

  • @Luffy-um8jo
    @Luffy-um8jo Год назад +1

    You cleared my doubt. Thanks

  • @k_usuan
    @k_usuan Год назад

    Thank you so much . I just feel happier doing it and experimenting while listening.

  • @aaronholt6595
    @aaronholt6595 Год назад

    🤣 massively appreciated the 'danger Will Robinson' comment half way through.

  • @manuelconte2127
    @manuelconte2127 2 года назад

    2022, still great explanation.

  • @priyapandey9219
    @priyapandey9219 2 года назад

    best explanation ever about this topic. I appreciate your skills.

  • @amalmokdad8880
    @amalmokdad8880 8 месяцев назад

    Truly incredible thank you for the explanation you're the best !

  • @sanaharmony8993
    @sanaharmony8993 2 года назад

    Thank you soooo much for making my school life so much easier!🥰

  • @Abhi1104
    @Abhi1104 11 дней назад

    Thanks for explaining simple

  • @ivankwapong6298
    @ivankwapong6298 2 года назад

    You made it so easy for me to understand these links. Thanks!

  • @MorkusReX
    @MorkusReX 4 года назад +4

    So with hard links, the two files claim they have size X, but actually only X is taken from the storage, correct?

  • @soundinducedflow
    @soundinducedflow 2 года назад +1

    Great explanation, thanks I get it.

  • @samucancld
    @samucancld 4 месяца назад

    Best video on the subject, thx

  • @kdedesko
    @kdedesko Год назад

    Nice job. Really good explanation.

  • @gardetanmay5457
    @gardetanmay5457 2 года назад

    CRISP AND CLEAR ,THANKS

  • @amirsaba80
    @amirsaba80 2 года назад

    Perfect explanation. thank you

  • @rohanwaghulkar3551
    @rohanwaghulkar3551 2 года назад

    Thank you... that was the best explanation

  • @trial000000000000001
    @trial000000000000001 Год назад

    Very Clear. Thank you

  • @etiniarchibong
    @etiniarchibong Год назад

    yes, it has been really informative and educative. Thanks

  • @LARPANET_3087
    @LARPANET_3087 Год назад

    Very clear explanation. Subscribed!

  • @zsoltory4176
    @zsoltory4176 5 лет назад

    Those familiar with C++11 or newer may find it helpful, to think of hard links somehow like right value reference, while soft link resemble to a normal (left value) reference. A left value reference references the name of an object, while the data itself is referenced via the ref assigned to that name. A right value reference references the content of a data object directly, without taking the detour trough the name.

  • @mohitswain8441
    @mohitswain8441 3 года назад

    Understandable! Have a nice Day!

  • @cohaisudethuongangnhinnhau6236

    thank you for your explanation

  • @linuxbd6769
    @linuxbd6769 3 года назад

    Beautiful explanation Sir.

  • @smartbear173
    @smartbear173 9 месяцев назад

    太清晰啦!谢谢!

  • @roathkanel
    @roathkanel 3 года назад +1

    Thank you very much for your video. This is very helpful to me to understand about how hard link and soft link work in linux. It would be great if you could provide an example where hard link is actually use in a real life.

    • @cbtnuggets
      @cbtnuggets  3 года назад

      Hi Kanel, thank you for your comment! We're glad you enjoyed the video. We recommend checking out this blog post on our website for more in-depth information into hard versus soft links: www.cbtnuggets.com/blog/certifications/open-source/linux-hard-links-versus-soft-links-explained

  • @eminedogan3125
    @eminedogan3125 2 года назад

    Thank you so much, super clear explanation!

  • @emilxrd
    @emilxrd Год назад

    thank you so much for this video!!

  • @moncefarajdal4582
    @moncefarajdal4582 2 года назад

    Thanks a lot for this video.

  • @vasilikipitsilou3599
    @vasilikipitsilou3599 2 года назад

    that's a great explanation.

  • @kennymccormic7578
    @kennymccormic7578 5 лет назад

    Thank you, sir! A perfect explanation!

  • @mahamadounouridinemamoudou9875
    @mahamadounouridinemamoudou9875 2 года назад +1

    thank a lot :)

  • @tejashwini54321
    @tejashwini54321 3 месяца назад

    Thank you so much sir

  • @jasonhuang4333
    @jasonhuang4333 2 года назад

    Good explanation!

  • @med3060
    @med3060 3 года назад

    thank you for the great explanation !

  • @MrVeriface
    @MrVeriface 4 года назад

    You're explanation saved me!

    • @cbtnuggets
      @cbtnuggets  4 года назад

      Glad to hear it! You've got this!

  • @bendustin7609
    @bendustin7609 8 месяцев назад

    Thank you!

  • @oktiennoeis3200
    @oktiennoeis3200 3 года назад

    Thank you, really good explained!!!

  • @justavideo24
    @justavideo24 Год назад

    Thank you very much

  • @divinomatheus6212
    @divinomatheus6212 9 месяцев назад

    That's an excellent video!
    But somethings still sounds a little bit confusing to me.
    If files are just references that point to an address on the hard drive where the values persists on. Where those references are persisted?

  • @allandossantosgama8597
    @allandossantosgama8597 Год назад

    very good. Thanks

  • @eilayyosfan4417
    @eilayyosfan4417 2 месяца назад

    a very good video thank you

  • @memedaddyz
    @memedaddyz 2 года назад +1

    just one question - are your full courses on website same amazing like here or they are good only on yt?

    • @cbtnuggets
      @cbtnuggets  2 года назад +1

      You can find the same great videos on the website!

  • @ArashArzandehnia
    @ArashArzandehnia 4 года назад

    Awesome Explanation such as always
    Thanks

  • @The1987Julian
    @The1987Julian Год назад

    5:37 Danger Will Robinson!!!

  • @julianalconcher7849
    @julianalconcher7849 9 месяцев назад

    AWESOME!

  • @abcjme
    @abcjme 6 лет назад +1

    Isn't a hard-link file the same as a duplicated file?

    • @jvsnyc
      @jvsnyc 5 лет назад +1

      There is only one real file no matter how many hard-links there are. If you duplicate a file five times, it takes five times as much space, and you can change any of them and that copy will change without changing any of the others.

  • @huntersneed4025
    @huntersneed4025 Год назад

    how does a hard link take more data if its pointing to the same spot in memory?

  • @ReToRx
    @ReToRx Год назад

    Thank you

  • @ilya_123__
    @ilya_123__ Год назад

    thank you!!!

  • @AishwaryaRadhakrishnan34
    @AishwaryaRadhakrishnan34 3 года назад

    Amazing explanation!

    • @cbtnuggets
      @cbtnuggets  3 года назад

      Glad you liked it, thank you for watching!

  • @darkmkv
    @darkmkv 4 года назад +1

    you da man! thank you

  • @yinonelbaz5309
    @yinonelbaz5309 2 года назад

    thanks a lot!!!

  • @user-uc7mi9nn1r
    @user-uc7mi9nn1r Год назад

    great job😀

  • @parkerchu5675
    @parkerchu5675 4 года назад

    Great video! Thank you

    • @cbtnuggets
      @cbtnuggets  4 года назад

      Glad you liked it, thank you Parker!

  • @asmrspace44
    @asmrspace44 4 года назад

    شرحك روعه 👍❤️ you are the best 😴

  • @5urg3x
    @5urg3x 4 года назад

    What was the original use case for hard links? I’m just not seeing why they were ever used in the first place.

  • @YannMetalhead
    @YannMetalhead 2 года назад

    Good video.

  • @rohithharidas5532
    @rohithharidas5532 10 месяцев назад

    thanks fam!

  • @PrashantSedhainOfficial
    @PrashantSedhainOfficial 4 года назад

    Thanks!

  • @RAJESHKUMAR-tr6rf
    @RAJESHKUMAR-tr6rf 6 лет назад

    really useful ......Thank u Sir

  • @magicandmagik
    @magicandmagik 7 лет назад

    thanks! loved the video

  • @zsoltory4176
    @zsoltory4176 5 лет назад

    I also use hard links to work on the same C++ project (on the same code base) with different ide, e. g. code::blocks and Kdevelop, using hardlinks on the code files (cpp,h,hpp)

  • @filippo7349
    @filippo7349 Год назад

    Today it's possible to create symlinks and hard links in Windows. Even hard links to directories (it's called junctions).

  • @ricko13
    @ricko13 3 года назад

    so if you have 100 hardlinks you gotta delete 'em all to actually free the space on the disk right?

  • @gogochannel1959
    @gogochannel1959 6 лет назад

    I found on google that softlinks take more space than hardlinks. Is it true?

  • @kb-zealot
    @kb-zealot 11 месяцев назад

    imo symlinks are the better option for most cases. I have never used hardlinks and no one that I know has either.

  • @linuxvoice1043
    @linuxvoice1043 7 месяцев назад

    nice
    good

  • @grantas3564
    @grantas3564 Год назад

    great

  • @android4261
    @android4261 5 лет назад +2

    Hi Shawn,
    thanks for this explanation and the video!
    You've mentioned, that in the case of two hard linked files, if you edit one, the other one gets edited also. But how come that if you delete one of the two files, the other one stays intact?

    • @krishreal2024
      @krishreal2024 5 лет назад +7

      Andro Id analogy: think of two people living at the same house . If you do reno(like edit) then both have to live through the reno. Now if one person decides to move , the other person will still live in the same house - the same address .

  • @diingyangloh8094
    @diingyangloh8094 Год назад

    Noice!

  • @rogernevez5187
    @rogernevez5187 5 лет назад +1

    I'm wondering when hard/soft links are useful ...

    • @azharahmed7588
      @azharahmed7588 5 лет назад

      I'm actually looking for that answer. I can say soft links are used as a short cut, you don't want to type absolute path when it's really long, instead create a soft link and use it to navigate. I still didn't understand the purpose of a hard link.

    • @choudhary6964
      @choudhary6964 5 лет назад

      @@azharahmed7588 when you give your pc to your evil sister or evil friend, they can't go in sudo "original file"
      But they may delete hard link file

  • @KarthikS30712
    @KarthikS30712 Год назад

    Ok.. So why are they used?

  • @Faladrin
    @Faladrin Год назад

    1:40 he points out that using a soft link takes up almost no space but doesn't mention this same fact for the hard link. Hard links also do not copy the actual file data and do not take up hardly any space (in fact hard links should usually take up slightly less space than soft links).

    • @Faladrin
      @Faladrin Год назад +1

      Watching the video again this guy seems to think the hard link file doubles the storage used, which it doesn't. The video has some serious flaws resulting from his misunderstanding of how this works.

  • @aqeelsapeeh
    @aqeelsapeeh 3 дня назад

    🤍🤍🤍

  • @csmania8263
    @csmania8263 4 года назад

    very clear explanation, thank you!

  • @BiblicalArchaeologyAR
    @BiblicalArchaeologyAR 3 года назад

    THANK YOU!

    • @cbtnuggets
      @cbtnuggets  3 года назад +1

      Glad it was helpful, R B! Thanks for watching the video.

  • @joe4343
    @joe4343 6 лет назад

    THANKS!!!!