LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1433|回复: 4

什么叫文件系统的硬连接和软连接?

[复制链接]
发表于 2004-12-5 22:27:58 | 显示全部楼层 |阅读模式
什么叫文件系统的硬连接和软连接?
发表于 2004-12-5 22:55:13 | 显示全部楼层
硬连接是对于同一文件系统的一个文件的连接,举个例子,目录中有A文件,用ln A B形成在当前目录下有一个B链接到A,此时用ls -li列出文件,可看到A与B文件的I节点是一样的,也就是说A与B是指向同一个文件的。I节点是文件存在的唯一标识,在文件系统中是唯一的,但在不同的文件系统则有可能重复。这样的话,在不同文件系统中作链接时,是不能使用ln A B,应该用符号连接,即是软连接,它只是包含了系统中一个完整的路径名引用
发表于 2004-12-6 02:20:01 | 显示全部楼层
In Linux it is possible to give more than one name to a file by
creating  links. Notice that Creating a link to a file is not the
same as creating a copy of the file! Links are divided to
hard and soft ones.

They can be used for different purposes and they have diffenet
characteristics and functionalities.

The general way for creating a hard link is the following:

ln file_name  link_name

Like:

ln mymemo  mymemo_link


You can check the number of hard links to a file or directory by
using ls -l command with the name of the file. For
example,  if I have a file called view.gif and use ls -l
to check its information, I'll see an output like the following:

Wed Nov 10-->ls -l view.gif
-rw-r--r--  1 mg users 0 Nov 10 11:50 view.gif


Number 1 in the secnd column tells us that there is only one hard
link, which refers to the physical content of the file on the drive. But
after we create another name for the file by making a hard link to it
in the following way:

ln view.gif viewln.gif

If we use ls -l  command to check the file information
again,
we will see the following output:


Wed Nov 10-->ls -l view.gif
-rw-r--r--  2 mg users 0 Nov 10 11:50 view.gif



Now, number 2 in the second column suggets that there are two
names, i.e. two hard links referring to the same physical contents.


The general way for creating a soft link is the following:

ln -s  file_name  link_name

Like:

ln -s  view.gif  view_slink.gif
发表于 2004-12-6 10:41:15 | 显示全部楼层
厉害。又学到了。
 楼主| 发表于 2004-12-7 14:11:55 | 显示全部楼层
谢谢个位拉!!

呵呵,要是每个解答都是英语解释,呵呵...................
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表