The difference between hard links and soft (or symbolic) links.

The difference between hard links and soft (or symbolic) links.

Image for post

It?s really not that hard.

The difference between hard links and soft (or symbolic) links comes down to what they reference.

Hard links point, or reference, to a specific space on the hard drive. You can have multiple files hard linked to the same place in the hard drive, but if you change the data on one of those files, the other files will also reflect that change.

Symbolic links work a bit differently. A symbolic link still points to a specific point on the hard drive, but if you create a second file, this second file does not point to the harddrive, but instead, to the first file.

Image for postinode represents the data physically on the drive

Implications =>

If you delete the ?my-hard-link? of a hard link, the remaining files pointing to that same space (inode) in the hard drive will still contain the data stored on the hard drive. But if you delete the main node (myfile.txt) in a symbolic link, you render the other links (my-soft-link) that are pointing to main node useless.

Hard links are more forgiving when you delete a file; soft links take up less data, but soft links don?t store the actual data, or the location of the original file.

Both types of links have their own quarks and uses. Creating them from the command line is easy.

ln {source} {link}

The {source} is the file that is already in existence, and {link} is the name of the file you want to create a hard link to.

To create a soft link, add the -s flag to the previous command

ln -s {source} {link}

Want to check the new link will run?

ls -l {source} {link}

19