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

You can make links to files and directories, and you can create links (shortcuts) on different partitions and with a different inode number than the original.

If the real copy is deleted, the link will not work.

A soft link (symbolic link) acts as a pointer or a reference to the file name. It does not access the data available in the original file. If the earlier file is deleted, the soft link will be pointing to a file that does not exist anymore.

2. Hard Links

Hard links are for files only; you cannot link to a file on a different partition with a different inode number.

If the real copy is deleted, the link will work, because it accesses the underlying data which the real copy was accessing.

A hard link acts as a copy (mirrored) of the selected file. It accesses the data available in the original file.
If the earlier selected file is deleted, the hard link to the file will still contain the data of that file.

How do I make a soft link?

A soft link can be made with ln -s; first you need to define the source and then you need to define the destination. (Keep in mind you need to define the full paths of both source and destination; otherwise it will not work.)

As you can see it has a different inode and can be made on a different partition.

How do I make a Hard link?

A Hard link can be made with ln; first you need to define the source and then you need to define the destination. (Keep it mind you need to define the full path of both source and destination; otherwise it will not work.)

Let’s say I have a script in the /script directory named firefox.

As you can see, it has the same inode. If I delete the original file, the link will still work, and it will act as the original.

--

--

--

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

Recommended from Medium

Google Interview problem solution

Bootcamp week 4: Hello my tetraminos!

How-to form submissions with Flask and AJAX

BlogPost 404

5 Basic Html5 Tags

JS Interview Help (pt 2): Hoisting, Currying, and Memoization

JavaScript: Asynchronous Operations

Unsubscribing From All YouTube Channels In One Go

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
Flavio Orlando

Flavio Orlando

More from Medium

My First Peace Protest As A Singaporean

Salutations to you all, blessed souls.

Finding Happiness Throughout a Stressful College Day

Unplugging and Detaching — What can a Digital Detox do to the Mind, Body, and Mental Health of an…