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.

最新文章

  1. 探索c#之Async、Await剖析
  2. 【LINUX】VI相关命令
  3. 怎么样修改PHPStorm中文件修改后标签和文件名的颜色与背景色
  4. SQL Server论坛楼层计算触发器
  5. 引入AOP 报错 error at ::0 formal unbound in pointcut
  6. [Python] Search navigation in Pycharm
  7. 初探JAVA中I/O流(二)
  8. 配置 Apache+php多端口多站点(转载)
  9. oracle 日期格式
  10. 八卦某 G 的前端开发方式及流程
  11. MySQL支持emoji
  12. MySQL 通配符学习总结
  13. cocos2d-x游戏开发 跑酷(四) 关联与物理世界
  14. Sql语句不等于空
  15. Docker - 容器互联
  16. java连接mysql源码
  17. JAVA NIO学习四:Path&Paths&Files 学习
  18. ~psd面试 求最长回文序列 DP求解
  19. mui 页面无法下滑拖拽 主要体现在华为手机浏览器
  20. JNI实战(一):JNI HelloWorld

热门文章

  1. 正确认识springcloud的作用。分布式从了解架构到springcloud支撑
  2. Java 设置、删除、获取Word文档背景(基于Spire.Cloud.SDK for Java)
  3. Catalina 默认使用zsh了,你可习惯
  4. 【MySQL】如何最大程度防止人为误操作MySQL数据库?这次我懂了!!
  5. 代码优化之return 减少括号嵌套
  6. 我的第一个程序Hello world
  7. jQuery的小测试
  8. offer收割机也有方法论
  9. Unix I/O
  10. 关于Java的对象,锁和对象的内存布局、访问定位