What is the difference between a hard link and a symbolic link?

Links are files that are located in any part of the hard drive of a device, let’s say a computer. There are two types: hard links and soft or symbolic links.

A hard link is a file that contains the same information of another file, but refers to an specific place in the hard drive, the spot where the other file is located in the hard drive. For instance, you can have to files with different wich refers to the same location and have the same stuff inside. Due to they are located in the same spot if changes are made in one this will be reflected in the other, but it is different when it is about removing files, when the real file is removed, the hard link remains having the originil information. You can think of them as same files with different names. It is possible to create a link a terminal using ln.

A soft link is a file, but unlike the hard one, this refers to another file, it is stored in the hardrive but ocuppies less space, we can think about it as the shorcuts (a file that shows where the real file is) we have in our desktop. This file has not the same information as the real file, it contains the name of that file, so if you remove or rename the real file the soft link won’t work, because it has not a reference anymore. In order to create a soft link we add an s (for symbolic) to the previous sintax: ln -s.

In the terminal image we can see 3 files, in blue a real file, in yellow a hard link and in green a soft link. It shows that the real link and the hardlink are exactly the same (have the same inode: contains information about a file) while the soft link is different.

For more information about hard and symbolic links see here.




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A powerful backend ready for your next app 🚀

How to Use the SectionList Component — React Native Basics


How to use svg icons in react-native

Destructuring in React

How to write reusable ReactJs components in Typescript

[E-news] 100k to be won!!! See how to win 20k from DJ nelly — for 5 lucky people.

Creating a Movies Finder App With React.js and OMDB API.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Atenea Castillo

Atenea Castillo

More from Medium

One of Many Reasons Young Men Are Choosing to Avoid College

Te Doy Mis Ojos (Take My Eyes, 2003) — film review

Datafying Your Emotions: How Would You Feel About That?

Life lessons that i learned from David Goggins through his book 'Cant Hurt Me'