You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ ln -s test test_1
$ ln -s test test_2
$ ll
-rw-r--r-- 1 xxx xx 29 Mar 8 15:33 test
lrwxrwxrwx 1 xxx xx 4 Mar 8 15:34 test_1 -> test
lrwxrwxrwx 1 xxx xx 4 Mar 8 15:34 test_2 -> test
硬链接 - hard link
不创建文件副本,为指向文件索引(只有索引为1时删除才会删除数据)
不可以跨文件系统(例如两个硬盘)
不能创建目录的硬链接
$ ln test test_3
$ ln test test_4
$ ll
-rw-r--r-- 3 xxx xx 29 Mar 8 15:33 test
lrwxrwxrwx 1 xxx xx 4 Mar 8 15:34 test_1 -> test
lrwxrwxrwx 1 xxx xx 4 Mar 8 15:34 test_2 -> test
-rw-r--r-- 3 xxx xx 29 Mar 8 15:33 test_3
-rw-r--r-- 3 xxx xx 29 Mar 8 15:33 test_4
test3test4 为硬链接, 所以引用数变为 3
删除原文件 test 后
软链接 test_1test2 不可用
硬链接 test_3test4 可用, 引用数变为 2
硬链接 test_3test4 可以访问内容
更改 硬链接 test_3 的内容, test4 也会改变
$ rm test
$ ll
lrwxrwxrwx 1 xxx xx 4 Mar 8 15:34 test_1 -> test
lrwxrwxrwx 1 xxx xx 4 Mar 8 15:34 test_2 -> test
-rw-r--r-- 2 xxx xx 29 Mar 8 15:33 test_3
-rw-r--r-- 2 xxx xx 29 Mar 8 15:33 test_4
ln 文件链接工具
symbolic link
hard link
软链接 - 符号链接 - symbolic link
硬链接 - hard link
test
后test_1
test2
不可用test_3
test4
可用, 引用数变为2
test_3
test4
可以访问内容test_3
的内容,test4
也会改变Reference
The text was updated successfully, but these errors were encountered: