Difference between hard link and symbolic link

Steffany Naranjo Vargas
2 min readJun 9, 2020

--

ln Command

The ln command is used to create links between files. Creating links is a kind of shortcuts to access a file. Links allow more than one file name to refer to the same file, elsewhere.

This is the syntax for ln command

They are two types of links hard links and soft or symbolic links.

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.

The command to create a hard link is:

the syntax for hard link

Symbolic or soft links

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.

The command to create a soft link is:

The syntax for soft link

Difference between Hard Link and Symbolic Links

These links behave differently when the source of the link (what is being linked to) is moved or removed. Symbolic links are not updated (they merely contain a string which is the pathname of its target); hard links always refer to the source, even if moved or removed.

Also a hard link doesn’t requires extra space and mat resolve faster, but the changes applied to a hard link reflect in the original file. On the other hand, Soft link needs extra space but any change in the soft link doesn’t impact the original file. Soft links are allowed to directories unlike to Hard link.

I hope this blog helps you to your work in linux.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Steffany Naranjo Vargas
Steffany Naranjo Vargas

No responses yet

Write a response