“Hello, I am writing you because we’ve been trying to reach you about your cars extended warranty, please proceed with the message and have your banking info on hand.”
Yeah… so if you’ve clicked the suspicious link in your browser and disregarded the advice not to… you’re in luck! This might be the only time you’ll ever receive a small nugget of knowledge from a potential scammer.
I am going to explain in layman’s terms what hard links and symbolic links are, what they do, and the key differences between them.
A hard link is a file that references or points to a spot on a hard drive, and that is where it stores its data. You can create multiple hard links that will point to the exact same spot on the hard drive. Take a look at this example here:
Essentially what you’ll have is two separate files that behave like separate files with the exception that if you make edits to File 1, then File 2 will automatically update to reflect the same changes BECAUSE they are pointing to the exact same spot on the hard drive. On the contrary, if we delete File 1, then File 2 will remain in tact and perfectly viable. Take a look at this live coding example below.
Now, symbolic links (or soft links) do work differently. The original file (File 1) does the same thing as before. It points to a spot on the hard drive where it stores its data.
When you create a symbolic link however, instead of another file that points to the same spot on the hard drive, this file just points to the original file descriptor. File 2 takes up little to no space because it is merely used as a “pointer” to the original file. If you delete File 1, File 2 becomes essentially useless because it is pointing at something that doesn’t exist. Take a look at this live coding example below.
P.S. On Linux, a portion of the filesystem is dedicated to inodes. An inode is a data structure that describes a file or a folder. It includes things like the owner, the group, permissions, file size, created/modified/access timestamps, and more. This is actually what you see beside every file listed in the live coding examples. Perhaps they will be talked about on a deeper level in a future post. :)
Something to always remember, hard links are more forgiving when you delete a file, and symbolic links take up less data (because it’s just a pointer) however, they don’t store actual data, only the location of the original file. Thank you for reading along, if you enjoyed please engage with me on Medium, and feel free to leave a comment on how I can make blog posts more intriguing and enjoyable in the future.