What is the Difference Between Soft link vs Hard link in Linux?

A link is a mechanism for creating a shortcut to the original file or directory. It contains information about another file or directory.

Links allow more than one filename to reference the same file.

What’s Soft link

A symbolic link, also known as a symlink or a soft link, is a special type of file that points to another file or directory on Linux.

It’s like a shortcut in Windows. It contains the path of the original file and not the contents.

In general Symbolic links are used to link libraries. Also, used to link log files and folders on mounted NFS (Network File System) shares.

What’s Hard link

Hard link is a mirror copy of the original file. Deleting the original file does not impact anything, because the hard link file serves as a mirror copy of the original file.

Why would you want to create a link file instead of copying them?

This is especially useful when you want to keep a same files in multiple location with updated contents.

When you copy a file to another location, it will copy the content and never get updated from the source file.

The contents of the file will be different from time to time.

The difference between Soft link vs Hard link

I’ve included possible difference between soft link and hard link in the table below.

S.NoSoft LinkHard Link
1The soft link is similar to the file shortcut on Windows.Hard link is a mirror copy of the original file.
2Soft link can be called Symbolic link or symlink.Hard link has no other name
3Changes in both file are reflected in the other.It's like a soft link.
4Soft links can be created on different file systems.Hard link can only be made on the same file system.
5Can create a soft link to files and directoriesOnly files can be linked
6It has different inode number and file permissions compared to the original file.It has the same inode number and file permissions.
7It contains the path of the original file and not the contents.It contains the actual contents of the original file.
8When the original file is removed, the link will die because it points to a non-existent file. This is called the hanging link.Nothing happens when the original file is removed.
9You can create a soft link with the following command (# ln -s [Source Filename] [Link Name])Hard link can be created using the following command (# ln [Source Filename] [Link Name])
10The soft link file contains a special symbol "l" in the file permission field.There is no special symbol for this.
11You can find the soft link file with the following command (# find / -type l)You can find the hard link file with the following command (# find / -samefile [Source Filename])
12A broken soft link can be found using the following command (# symlinks [Path/to/Directory]).Not applicable

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...