Hard links and soft links in Linux
Soft links and Hard links
Command LN
LN is the command to create the link:
To create a hard link:ln file link
To create a soft link:ln-s file Link
Hard Links
Hard link (hard link) is the earliest way to create a link in a UNIX system.
By default, each file has a hard link, and when you create a hard link, you actually create an additional entry, and the file is actually deleted when all the hard links to the file are deleted, that is, the data block is cleaned up.
Create a hard link for a file, similar to copying a file, but the new copy and the original version are synchronized updates.
This is because all files in the Linux file system are assigned a number, called Index node number (inode index), create hard links, the Inode is the same number, so you can synchronize updates.
Two restrictions on hard links:
1. Hard links cannot point to files outside of their own file system, that is, they cannot be partitioned across hard disks (soft links can be).
2. Hard links cannot point to directories.
Soft links
Soft links (software link), also known as Symbolic links (symbolic link), can be likened to shortcuts on Windows.
Deleting a soft link does not affect the point to the file, and if you delete the file without deleting the soft link, the link exists but does not point to it, which is broken.
Summarize
Hard Links: Copy + Sync
Soft Links: Shortcuts
Thank you for reading, I hope to help you, thank you for your support for this site!