MicroNuggets: Hard Links versus Soft Links Explained

  Рет қаралды 67,462

CBT Nuggets

CBT Nuggets

Күн бұрын

Start learning cybersecurity with CBT Nuggets. courses.cbt.gg...
In this video, Shawn Powers covers the difference between hard links and soft (or symbolic) links on a Linux OS 10 operating system. These are essentially two different ways that files are referenced on a hard drive, with the former pointing to the file itself and the latter directed towards the name of the file.
There are two primary types of links on a Linux OS 10: hard and soft (sometimes referred to as “symbolic”). A hard link begins with referencing a file that points to a specific spot on a hard drive where that data is stored. When you create a second file that points to the same location, it’s referred to as a hard-linked file. These two files behave separately except for one crucial distinction: when you change the data on one file, it updates the data in the other to reflect the changes. In a soft link, the original file is still located at a specific point on the hard drive. When a secondary file is created and soft-linked, the only role that secondary file plays is to point to the file one descriptor or name.
📁 Download the Ultimate Sysadmin Cert Guide: blog.cbt.gg/ttri
⬇️ 4-Week Study Plan: MD-100 & MD-101: blog.cbt.gg/p4ym
Start learning with CBT Nuggets:
• Linux Security | courses.cbt.gg...
• Everything Linux | courses.cbt.gg...
• Linux Bash Training | courses.cbt.gg...
• Linux Essentials | courses.cbt.gg...

Пікірлер: 111
@jvsnyc
@jvsnyc 5 жыл бұрын
This is a better explanation than most on KZbin, 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 жыл бұрын
This is the best explanation I've found on KZbin. Thank you sooooo much for making the concept of soft link and hard link so clear.
@cbtnuggets
@cbtnuggets 3 жыл бұрын
Glad it was helpful!
@Adedayodeji
@Adedayodeji Жыл бұрын
Entirely true!
@param2609-p9m
@param2609-p9m Жыл бұрын
Right🎉
@mattr7229
@mattr7229 Жыл бұрын
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 жыл бұрын
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.
@annexgroup6878
@annexgroup6878 3 жыл бұрын
Im so glad you use visuals. Thank you so much for explaining this.
@beto.aveiga
@beto.aveiga 2 жыл бұрын
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 2 жыл бұрын
Agreed, do you have an example of practical usage for these two concepts?
@JpsBookOfLife
@JpsBookOfLife Жыл бұрын
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.
@ransazz
@ransazz Жыл бұрын
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!
@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!
@bouhannacheabdallah
@bouhannacheabdallah 4 жыл бұрын
Among so many videos u r the first. One that gave the correct way of explanation
@cbtnuggets
@cbtnuggets 4 жыл бұрын
Thank you so much 🙂
@Devildoc512
@Devildoc512 7 ай бұрын
wow, that was a perfect presentation!
@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
@aaronholt6595
@aaronholt6595 Жыл бұрын
🤣 massively appreciated the 'danger Will Robinson' comment half way through.
@antosolisr
@antosolisr Жыл бұрын
gracias, es mil veces mejor su explicacion de menos de 10 minutos que horas de clase en mi universidad: UNLAM.
@priyapandey9219
@priyapandey9219 2 жыл бұрын
best explanation ever about this topic. I appreciate your skills.
@Luffy-um8jo
@Luffy-um8jo Жыл бұрын
You cleared my doubt. Thanks
@k_usuan
@k_usuan Жыл бұрын
Thank you so much . I just feel happier doing it and experimenting while listening.
@amalmokdad8880
@amalmokdad8880 8 ай бұрын
Truly incredible thank you for the explanation you're the best !
@ivankwapong6298
@ivankwapong6298 2 жыл бұрын
You made it so easy for me to understand these links. Thanks!
@MorkusReX
@MorkusReX 4 жыл бұрын
So with hard links, the two files claim they have size X, but actually only X is taken from the storage, correct?
@Mark-nm9sm
@Mark-nm9sm Жыл бұрын
best explanation hands down. Thank you
@sanaharmony8993
@sanaharmony8993 2 жыл бұрын
Thank you soooo much for making my school life so much easier!🥰
@manuelconte2127
@manuelconte2127 2 жыл бұрын
2022, still great explanation.
@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?
@das1992
@das1992 7 күн бұрын
Thank You for the great explanation.
@kdedesko
@kdedesko Жыл бұрын
Nice job. Really good explanation.
@malborocomun
@malborocomun 5 ай бұрын
Best video on the subject, thx
@amirsaba80
@amirsaba80 2 жыл бұрын
Perfect explanation. thank you
@gardetanmay5457
@gardetanmay5457 2 жыл бұрын
CRISP AND CLEAR ,THANKS
@soundinducedflow
@soundinducedflow 2 жыл бұрын
Great explanation, thanks I get it.
@roathkanel
@roathkanel 3 жыл бұрын
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
@Abhi1104
@Abhi1104 24 күн бұрын
Thanks for explaining simple
@rohanwaghulkar3551
@rohanwaghulkar3551 2 жыл бұрын
Thank you... that was the best explanation
@trial000000000000001
@trial000000000000001 Жыл бұрын
Very Clear. Thank you
@memedaddyz
@memedaddyz 2 жыл бұрын
just one question - are your full courses on website same amazing like here or they are good only on yt?
@cbtnuggets
@cbtnuggets 2 жыл бұрын
You can find the same great videos on the website!
@LARPANET_3087
@LARPANET_3087 Жыл бұрын
Very clear explanation. Subscribed!
@linuxbd6769
@linuxbd6769 3 жыл бұрын
Beautiful explanation Sir.
@mohitswain8441
@mohitswain8441 3 жыл бұрын
Understandable! Have a nice Day!
@The1987Julian
@The1987Julian Жыл бұрын
5:37 Danger Will Robinson!!!
@smartbear173
@smartbear173 9 ай бұрын
太清晰啦!谢谢!
@etiniarchibong
@etiniarchibong Жыл бұрын
yes, it has been really informative and educative. Thanks
@cohaisudethuongangnhinnhau6236
@cohaisudethuongangnhinnhau6236 Жыл бұрын
thank you for your explanation
@emilxrd
@emilxrd Жыл бұрын
thank you so much for this video!!
@moncefarajdal4582
@moncefarajdal4582 2 жыл бұрын
Thanks a lot for this video.
@jasonhuang4333
@jasonhuang4333 2 жыл бұрын
Good explanation!
@vasilikipitsilou3599
@vasilikipitsilou3599 2 жыл бұрын
that's a great explanation.
@abcjme
@abcjme 6 жыл бұрын
Isn't a hard-link file the same as a duplicated file?
@jvsnyc
@jvsnyc 5 жыл бұрын
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.
@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.
@MrVeriface
@MrVeriface 4 жыл бұрын
You're explanation saved me!
@cbtnuggets
@cbtnuggets 4 жыл бұрын
Glad to hear it! You've got this!
@eminedogan3125
@eminedogan3125 2 жыл бұрын
Thank you so much, super clear explanation!
@kennymccormic7578
@kennymccormic7578 5 жыл бұрын
Thank you, sir! A perfect explanation!
@huntersneed4025
@huntersneed4025 Жыл бұрын
how does a hard link take more data if its pointing to the same spot in memory?
@tejashwini54321
@tejashwini54321 4 ай бұрын
Thank you so much sir
@mahamadounouridinemamoudou9875
@mahamadounouridinemamoudou9875 2 жыл бұрын
thank a lot :)
@justavideo24
@justavideo24 Жыл бұрын
Thank you very much
@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)
@allandossantosgama8597
@allandossantosgama8597 Жыл бұрын
very good. Thanks
@eilayyosfan4417
@eilayyosfan4417 3 ай бұрын
a very good video thank you
@oktiennoeis3200
@oktiennoeis3200 3 жыл бұрын
Thank you, really good explained!!!
@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.
@bendustin7609
@bendustin7609 8 ай бұрын
Thank you!
@ArashArzandehnia
@ArashArzandehnia 4 жыл бұрын
Awesome Explanation such as always Thanks
@cbtnuggets
@cbtnuggets 4 жыл бұрын
Thank you, Arash!
@android4261
@android4261 5 жыл бұрын
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 жыл бұрын
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 .
@ricko13
@ricko13 3 жыл бұрын
so if you have 100 hardlinks you gotta delete 'em all to actually free the space on the disk right?
@AishwaryaRadhakrishnan34
@AishwaryaRadhakrishnan34 3 жыл бұрын
Amazing explanation!
@cbtnuggets
@cbtnuggets 3 жыл бұрын
Glad you liked it, thank you for watching!
@ReToRx
@ReToRx Жыл бұрын
Thank you
@julianalconcher7849
@julianalconcher7849 9 ай бұрын
AWESOME!
@asmrspace44
@asmrspace44 4 жыл бұрын
شرحك روعه 👍❤️ you are the best 😴
@ilya_123__
@ilya_123__ Жыл бұрын
thank you!!!
@yinonelbaz5309
@yinonelbaz5309 2 жыл бұрын
thanks a lot!!!
@宋承亮-l6q
@宋承亮-l6q Жыл бұрын
great job😀
@darkmkv
@darkmkv 4 жыл бұрын
you da man! thank you
@YannMetalhead
@YannMetalhead 2 жыл бұрын
Good video.
@Faladrin
@Faladrin 2 жыл бұрын
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 2 жыл бұрын
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.
@parkerchu5675
@parkerchu5675 4 жыл бұрын
Great video! Thank you
@cbtnuggets
@cbtnuggets 4 жыл бұрын
Glad you liked it, thank you Parker!
@filippo7349
@filippo7349 Жыл бұрын
Today it's possible to create symlinks and hard links in Windows. Even hard links to directories (it's called junctions).
@gogochannel1959
@gogochannel1959 6 жыл бұрын
I found on google that softlinks take more space than hardlinks. Is it true?
@RAJESHKUMAR-tr6rf
@RAJESHKUMAR-tr6rf 6 жыл бұрын
really useful ......Thank u Sir
@rohithharidas5532
@rohithharidas5532 11 ай бұрын
thanks fam!
@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.
@PrashantSedhainOfficial
@PrashantSedhainOfficial 4 жыл бұрын
Thanks!
@magicandmagik
@magicandmagik 7 жыл бұрын
thanks! loved the video
@rogernevez5187
@rogernevez5187 5 жыл бұрын
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?
@grantas3564
@grantas3564 Жыл бұрын
great
@linuxvoice1043
@linuxvoice1043 7 ай бұрын
nice good
@diingyangloh8094
@diingyangloh8094 2 жыл бұрын
Noice!
@aqeelsapeeh
@aqeelsapeeh 16 күн бұрын
🤍🤍🤍
@med3060
@med3060 3 жыл бұрын
thank you for the great explanation !
@BiblicalArchaeologyAR
@BiblicalArchaeologyAR 3 жыл бұрын
THANK YOU!
@cbtnuggets
@cbtnuggets 3 жыл бұрын
Glad it was helpful, R B! Thanks for watching the video.
@csmania8263
@csmania8263 4 жыл бұрын
very clear explanation, thank you!
@cbtnuggets
@cbtnuggets 4 жыл бұрын
Glad it was helpful!
@joe4343
@joe4343 6 жыл бұрын
THANKS!!!!
Understanding Linux and UNIX inodes and file metadata
13:46
theurbanpenguin
Рет қаралды 130 М.
Compressing with Gzip and Bzip2 in Linux
11:25
CBT Nuggets
Рет қаралды 9 М.
💩Поу и Поулина ☠️МОЧАТ 😖Хмурых Тварей?!
00:34
Ной Анимация
Рет қаралды 1,7 МЛН
Bike Vs Tricycle Fast Challenge
00:43
Russo
Рет қаралды 86 МЛН
Brawl Stars Edit😈📕
00:15
Kan Andrey
Рет қаралды 51 МЛН
Hard and Soft Links in Linux
18:07
Jason Wertz
Рет қаралды 120 М.
Linux inodes Explained
8:53
tutoriaLinux
Рет қаралды 73 М.
Linux Crash Course - Symbolic Links
30:07
Learn Linux TV
Рет қаралды 62 М.
"Everything is a file" in UNIX
11:14
Stevie Jay
Рет қаралды 45 М.
What is Redis and What Does It Do?
6:47
CBT Nuggets
Рет қаралды 258 М.
SymLinks: The Hidden "SUPER Shortcut" Feature in Windows
14:23
Linux Crash Course - The /etc/fstab file
30:29
Learn Linux TV
Рет қаралды 105 М.
Demystifying "find" and "find -exec" ...Lil' Linux Lesson!
8:12
Veronica Explains
Рет қаралды 50 М.
Symbolic Links in Linux | Use SymLinks for Anything
8:19
Chris Titus Tech
Рет қаралды 91 М.
💩Поу и Поулина ☠️МОЧАТ 😖Хмурых Тварей?!
00:34
Ной Анимация
Рет қаралды 1,7 МЛН