与你常在

链接文件分为软连接和硬链接

创建硬链接

ln /root/aa.txt /root/test

ln 源文件 目标文件

原理:在某个目录下添加一条文件名到inode的链接。链接文件和原文件有相同的inode

读取文件必须要经过目录记录的文件名来指向正确的inode号码来读取,目录的block块如下:

文件名 文件名对应的inode
file1 232321
file2 432432

在其他目录建立硬链接后

文件名 文件名对应的inode
file1-link 232321
….

创建软链接

ln -s /root/aa.txt /root/test