In linux, there are two types of link, namely : Soft link and Hard link. These link are created by usage of ‘ln‘ command. For more on ‘ln’ command, type
$ ln --h
to get help.
1. Soft link
In linux, there’s a special file type whose data part carries a path to another file. The data in the original file can be accessed through the special file, which is called as Soft Link. Soft link is also called symbolic link or symlink.
To create a soft link :
$ ln -s {/path/to/file-name} {link-name} $ ln -s /home/pj/Documents/abc.txt xyz.txt $ ls -l sales.data.txt
To delete a soft link:
$ rm {link-name} $ rm xyz.txt $ ls -l /home/pj/Documenst/abc.txt
When a soft link is deleted, original file/directory is not deleted only link is removed, but when original file/direcltory is deleted the link is broken and data is lost.
2. Hard link
A hard link is merely an additional name for an existing file on Linux. The original name and any hard links all point to the same inode.
To create a hardlink:
$ ln {file.txt} {hard-link} $ ln /home/pj/abc.txt xyz-link
To delete a hard link:
$ rm {hard-link} $ rm xyz-link
Soft link refer to a symbolic path indicating the abstract location of another file.
Hard link cannot link files across drives, partition. They cannot links directrories.
References:
Linux Gazette
What is Hard link?
The Geek Stuff