软链接文件和硬链接文件的区别
侧边栏壁纸
  • 累计撰写 18 篇文章
  • 累计收到 3 条评论

软链接文件和硬链接文件的区别

无冕の神
2026-02-03 / 0 评论 / 1 阅读 / 正在检测是否收录...

1.当原文件发生修改时,软链接文件和硬链接文件内容都会发生修改
​ 2.当软连接文件和硬链接文件发生修改时,原文件也会发生修改
​ 3.当软链接文件和硬链接文件被删除时,原文件不受影响
​ 4.当原文件删除时,软链接失效,硬链接文件正常使用
​ 5.软链接文件可以跨分区跨文件系统创建,硬链接文件不可以
​ 6.硬链接文件不会分配独立的inode,软链接文件会分配独立的inode

验证跨分区文件系统创建软链接文件和硬链接文件
[root@localhost mnt]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/nvme0n2p1 ext4 974M 587M 321M 65% /mnt/mountpoint
/dev/nvme0n2p2 ext4 974M 24K 907M 1% /mnt/mountpoint2
[root@localhost mnt]# touch /mnt/mountpoint/testfile
[root@localhost mnt]# ln -s /mnt/mountpoint/testfile /mnt/mountpoint2/softfile
[root@localhost mnt]# ln /mnt/mountpoint/testfile /mnt/mountpoint2/hardfile
ln: failed to create hard link '/mnt/mountpoint2/hardfile' => '/mnt/mountpoint/testfile': Invalid cross-device link

0

评论 (0)

取消