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