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

By Shawn Powers from CBT Nuggets: https://www.youtube.com/watch?v=lW_V8oFxQgA

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.