Roadmap to becoming a developer in 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

1.1 KiB

Soft and Hard Links

In Unix-like operating systems like Linux, soft (symbolic) and hard links are simply references to existing files that allow users to create shortcuts and duplication effects within their file system.

A hard link is a mirror reflection of the original file, sharing the same file data and inode number, but displaying a different name. It's vital to note that if the original file is deleted, the hard link still retains the file data.

On the other hand, a soft link, also known as a symbolic link, is more like a shortcut to the original file. It has a different inode number and the file data resides only in the original file. If the original file is removed, the symbolic link breaks and will not work until the original file is restored.

Below is an example of how to create a soft link and a hard link in Linux:

# Create a hard link
ln source_file.txt hard_link.txt

# Create a soft link
ln -s source_file.txt soft_link.txt

Please, understand that source_file.txt is the original file and hard_link.txt & soft_link.txt are the hard and soft links respectively.