13

Linux中软连接和硬连接的区别

 4 years ago
source link: http://www.cnblogs.com/loliconinvincible/p/12442230.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

首先,我们要清楚符号链接的目的,在不改变原目录/文件的前提下,起一个方便的别名(在这起个别名,让我想到前阶段学C里typedef也是起别名的)。

1. 软连接就相当于windows的快捷方式

例如:ln -s /data/dir /tmp/aaa

ln -s 源目录,目标软连接

进入软连接。

cd/tmp/aaa

实际上aaa这个软连接就相当于/data/dir了。

2. 至于硬连接,比软连接更实际,虽然他不能做目录的链接,不过它的稳定性更高

先通俗的介绍一下硬连接:当你删除链接文件时,在利用软连接去读取这个文件,会出现错误,硬连接不会,他依旧可以读取到这个文件。。

要明白这个问题,你要先搞清楚linux的i节点。

Linux的每个设备都是以文件方式读取的,i节点就记录这个文件的所有必要信息,以及这个文件的存储块位置。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK