转载:Linux: What’s the difference between a soft link and a hard link?
Link:https://www.moreofless.co.uk/linux-difference-soft-symbolic-link-and-hard-link/
This example shows the difference between a soft (also known as a symbolic link) and a hard link on a Linux system:
echo "hello" > a ---> create a file called "a"
ln a b ---> create hard link called "b" to "a"
ln -s a c ---> create soft link called "c" to "a"
No surprises here, printing the contents of files a, b and c produce the same result:
cat a ---> hello
cat b ---> hello
cat c ---> hello
Now we remove the original “a” file:
rm a
And the difference between the two links become obvious:
cat a ---> No such file or directory
cat b ---> hello
cat c ---> No such file or directory
The soft link is essentially a pointer to the original file and when the original file is deleted the soft link does not point to anything and so “no such file or directory” is reported. The hard link acts more like a mirror of the original file, it actually points to the same “node” in the filesystem that the original “a” file points to, so when we delete the original file “a” the file “c” still points to the same (and still existing) node in the filesystem.