Why we create soft link in Linux?

Soft Link contains the path for original file and not the contents. Removing soft link doesn’t affect anything but removing original file, the link becomes “dangling” link which points to nonexistent file. A soft link can link to a directory.

A symbolic link, also termed a soft link, is a special kind of file that points to another file, much like a shortcut in Windows or a Macintosh alias. Unlike a hard link, a symbolic link does not contain the data in the target file. It simply points to another entry somewhere in the file system.

Why use symbolic links? You can operate on symlinks as if they were the actual files to which they pointing somewhere down the line (except deleting them). This allows you to have multiple “access points” to a file, without having excess copies (that remain up to date, since they always access the same file).

A soft link (also known as Symbolic link) acts as a pointer or a reference to the file name. It does not access the data available in the original file.

Soft Link :

Comparison Parameters Hard link Soft link
File system It cannot be used across file systems. It can be used across file systems.

To make links between files you need to use ln command. A symbolic link (also known as a soft link or symlink) consists of a special type of file that serves as a reference to another file or directory. Unix/Linux like operating systems often uses symbolic links.

To remove a symbolic link, use either the rm or unlink command followed by the name of the symlink as an argument. When removing a symbolic link that points to a directory do not append a trailing slash to the symlink name.

Symbolic links are used all the time to link libraries and make sure files are in consistent places without moving or copying the original. Links are often used to “store” multiple copies of the same file in different places but still reference to one file.

Hard link is the exact replica of the actual file it is pointing to . Both the hard link and the linked file shares the same inode . If the source file is deleted ,the hard link still works and you will be able to access the file until the number of hard links to file isn’t 0(zero).

The reason hard-linking directories is not allowed is a little technical. Essentially, they break the file-system structure. You should generally not use hard links anyway. Symbolic links allow most of the same functionality without causing problems (e.g ln -s target link ).

A hard link is merely an additional name for an existing file on Linux or other Unix-like operating systems. Any number of hard links, and thus any number of names, can be created for any file. Hard links can also be created to other hard links.

Like this post? Please share to your friends:
OS Today